jczic / MicroWebSrv

A micro HTTP Web server that supports WebSockets, html/python language templating and routing handlers, for MicroPython (used on Pycom modules & ESP32)
https://github.com/jczic/MicroWebSrv
MIT License
640 stars 115 forks source link

stack overflow serving small pyhtml page #79

Open nicciniamh opened 1 year ago

nicciniamh commented 1 year ago

This is on esp32 v2 wroom devit, micropython version 1.19.1

---- crash report ---

from microWebSrv import MicroWebSrv import microWebTemplate

mws = None mws = MicroWebSrv( ... [], ... 80, ... '0.0.0.0', ... '/www') mws.Start(threaded=True)

ERROR A stack overflow in task mp_thread has been detected.

Backtrace:0x40093b5e:0x3ffd8ba0 0x400942d5:0x3ffd8bc0 0x400944a6:0x3ffd8be0 0x400952f8:0x3ffd8c50 0x 4009459c:0x3ffd8c80 0x40094552:0x3f41b184 |<-CORRUPTED

ELF file SHA256: 00495403985fb7e0

--- pyhtml file ---

e32::temperature
{{ py }} import temptask {{ end }} Temperature is {{ '{.2f}.format(temptask.temp) }}° Humidity is {{ '{:.2f}'.format(temptask.hum) }}% ---- end
jczic commented 1 year ago

Hello @nicciniamh and thank you for your feedback. It seems to me that this type of error when using pyhtml occurs frequently if there are too many recursive calls (functions in depth). It is perhaps not the problem that you meet but there are great chances that the stack is exceeded in number of calls. I think I remember, there is a variable indicating the size of the default stack depth in MicroPython that can be modified for the compilation of the firmware. (pyhtml is greedy in stack usage).

Have you tried to use MicroWebSrv2 ?