Sure, just to clarify, you are printing a string that is greater than around 8000 characters to the terminal throws a stack overflow. (I agree, now that could be a separate issue also with string.char/string.byte…anyway…)
Firstly, I’d write a program that generates a string > 8000 characters and prints that to the terminal. If okay (no stack overflow, no crash etc…), I’d assume that the string returned from ‘device.active_preset_data’ (which in your case above is around 32226 characters long) causes a crash when printed to the terminal. To me it feels an internal Lua/Renoise thing for taktik to look at (you’ve basically found a bug. [Only Ledger could want to print an entire large CDATA VST parameter string to the terminal, but well done for the effort ])
Maybe work out a command that prints just partially the head and tail of the string? Or make sure you can output the entire string say to a file etc…? Things like that. But I know what you mean Ledger when you say there could be something else going on more here. A bit more testing is definitely needed, but also testing from the internal Renoise/Lua side. Hmm, you go and test string allocation/deallocation in Renoise/Lua Ledger…err… while I put the kettle on
[Edit:] The other thing to note is to see if the same thing happens under Linux x64.
[Edit2:] Actually just quickly testing under Linux, your snippet Ledger seems to be fine. It pauses a moment, but it does print the entire string (at a length of 37656 characters in my case) to the terminal…albeit it doesn’t much care for it been in the terminal.
Whereas my string.char/string.byte combo is still limited to 7997 characters before a stack overflow…Wait! string.byte puts the parameters i.e. each character as a parameter on the stack. Of course! The parameter stack under Lua is probably 8 KB (8192 bytes) in length, hence why you get the stack overflow error. Okay, forget my crude string limiter, it’s confusing the issue.
So ultimately its a Windows issue moreso, Linux seems to handle it a bit better but not maybe ideal (can’t try Mac OSX), only taktik can look at it properly. I still say a cup of tea is in order though