Recursive Function Hanging #5949
Replies: 1 comment
-
Posted at 2017-12-29 by @allObjects ...it is always the same issue: Active executing code in level 0 messes with the upload completion detection from editor as well as console, and in your case it is even worse: your Put your function invocation code into a function (which you call within) PS: without the convenience of last code line (
Posted at 2017-12-29 by calebbrewer Thank you! When I run it with the onInit() I get this...
Posted at 2017-12-29 by @MaBecker @user84505 looks like you found a ESP8266 specific hard limit or bug My device freezes or resets with cause 2 or 4, if there are more than eleven entires in Posted at 2017-12-30 by @allObjects looks like stack overflow... I though assume @gfwilliams would make that fail more gracefully. So I go for the cpu hog-ing for longer then allowed on the ESP8266 platform. There is a limit - in ms - that another process than the ESP8266 core (tending to WiFi) can hog the CPU... Normally, a piece of JavaScript is triggered by a Hardware, for example, pin state change (setWatch), timer (incl. setTimeout(), setInterval()), and communication (data sent, received data available) event, and ends within that time frame serving these events. After serving by the JS interpreter, control returns to ESP8266 core first, and if it goes idle, the next piece of JS is picked up if there are still events for it in the event queue. ESP8266 is just not the platform to run two sophisticated systems on a single processor...Wifi is - time wise -just too demanding and leaves only little computing resources to other activities. Therefore, Espruino-Wifi or a plain Original or Pico combined with a ESP8266 (ESP-01) are the solution: ESP8266 has enough juice to tend to Wifi and have communication with the host-mc over serial. The host-mc works the application code and communicates to ESP8266 over the serial. Posted at 2017-12-30 by @MaBecker switching to a build with debug info you get this details:
Posted at 2017-12-30 by @allObjects @MaBecker, thanks for the in-depth information... not a stack overflow but something of a similar pattern: In Espruino automatic memory management / garbage collection support, a variable can obviously only 'be held hostage' (be locked 'up') by max. 15 running contexts... (or what ever the context's naming by @gfwilliams is)... which at the same time limits also the calling / call stack depth. This may be variable per platform depending on available memory? Posted at 2017-12-31 by @MaBecker JSV_LOCK_MAX is hard coded for every platform, see src/jsutils.h Posted at 2017-12-31 by calebbrewer Thanks @MaBecker & @allObjects! Why does this need to be locked/limited? recursion is a big deal in JS. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2017-12-29 by calebbrewer
I am running 1v95.4 on the NODE MCU ESP8266 dev board. When I run this code...
I get this...
Some times it will make it to 16, but it always hangs. Does anyone know what may be happening here?
Beta Was this translation helpful? Give feedback.
All reactions