[BUG] stack overflow error

When running this minimal actor with n > 39

actor Test {
    public query func example(n : Nat) : async Text{
        var output : Text = "\n";
        var current_row: Nat = 0;

        for (index in Iter.range(0,n*n-1)){
            
            if (index/n > current_row){
                output #= "\n";
                current_row += 1;
            };

            output #= "◼";

        };

        return output;
    };
};

it will fail with the following error:

Mar 21 17:31:31.284 WARN Could not perform query on canister: IC0502: Canister ic:9888BAFBFF1508D5AC trapped: stack overflow, Application: Http Handler

Somehow it seems like a Text can’t contain more than 1634 characters?

@enzo @alexa.smith @claudio

1 Like

Woops, looks like this bug slipped through the cracks.
I’ll file an issue internally with a link to the forum article.
I expect what is going on is a stack overflow in the code for text concatenation.

Claudio

3 Likes