Closed petermm closed 7 months ago
I wouldn't personally write it is due to the sdkconfig but rather that a workaround is to edit the sdkconfig.
I believe it is a deeper bug.
I wouldn't personally write it is due to the sdkconfig but rather that a workaround is to edit the sdkconfig.
I believe it is a deeper bug.
agreed, updated issue.
The crash happens inside esp-idf when calling esp_wifi_init()
, and it can be reproduced enabling CONFIG_COMPILER_OPTIMIZATION_PERF=y
.
It can be fixed setting as default pthread stack size (that is 3072) to the same used for main task, such as CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3584
, but even a smaller value works (such as 3200
).
I think that esp_wifi_init()
in most firmwares around is called from main, so likely it has been tested mostly with 3584 bytes stack.
I have 2 hypothesis about this bug:
increased execution speed causes a different scheduling order, that makes the network initialization running on the pthread rather than the main task
I suggest changing stack size for any created scheduler thread in order to match the same stack size used to main, so behavior is consistent independently from which scheduler has been used.
Changing sdkconfig works too, but I don't think that increasing the default size for all threads is the right thing to do.
Erased device - flashing release img for S3, and booting that (eg NOT flashing own app avm) stack overflows repeatedly:
replicate on device:
erase and flash S3 device - say on https://petermm.github.io/atomvm-web-tools/ - connect to console and see crashing..
replicate on wokwi:
download s3 release image - go to a wokwi S3 board eg https://wokwi.com/projects/390468884528509953 - press F1 - use "Upload Firmware and Start simulation" and upload S3 image - see it crash.. (stop the sim, as it will crash loop)
Local build replication:
crash only shows up if one copies the release-defaults in and build with that https://github.com/atomvm/AtomVM/blob/main/src/platforms/esp32/sdkconfig.release-defaults (they are copied in only on release GH builds).
Guess:
Some bug in code path for invalid_avm - that only surfaces on -O2.