"cannot push beyond allocated stack" fatal error.
-
Turns out it is quite easy to cause what looks like an Flic Hub (Firmware: 3.0.12) internal stack error. This (non recursive) code runs perfectly on a regular web browser but will crash after 55 iterations on the hub.
var counter =0; function stacksize() { err = new Error(); return err.stack.split("\n").length-1; } function run() {console.log("iteration "+counter+" / stack size ="+ stacksize() ); counter++; setTimeout(run,1); } run();
Here are the results on the SDK console:
iteration 54 / stack size =2 iteration 55 / stack size =2 FATAL ERROR: uncaught: 'cannot push beyond allocated stack'
A workaround is to use setInterval()
function run() { console.log("iteration "+counter+" / stack size ="+ stacksize() ); counter++; } setInterval(run,1)
But it's not a perfect solution, with some slightly more complex (but still non recursive) code, the 'cannot push beyond allocated stack' error will randomly appear again.
The "Restart after crash" option doesn't seem to have any effect, at least on this error.
Long story short, I'm under the impression that the hub SDK is a nice little toy, but it is unfortunately too limited/unreliable for even basic "real life" applications.
-
@martinm Hi!
Excellent bug report, thank you!
This has been fixed in the new firmware that is currently in beta. If you want to try it out, please PM me your hub serial number and I can assign the new firmware to your hub.