Native machine code bss corruption
Posted: Fri Oct 30, 2020 12:17 pm
Using current master, I built a Python module with native code for a ESP32 board. The module loads fine, and seems to work at first. however, after a while the calculations made in native code seemed off. I failed reproducing the issue on x64. It happened on two independent boards (GENERIC and TINYPICO).
I then noticed that when I force the garbage collector between calls to my module, it started to produce the expected results. The algorithm uses a rather large struct to store its state (which is in bss).
I then tried to reproduce this using the examples, and corruptions/crashes do happen from time to time when playing with the features1 example:
I have to start that 2 or 3 times for things to get weird. It doesn't seem to corrupt the features1 heap (at least the value mostly look good), but it crashes from time to time and FAT file system corrupts as well.
Are there known issues with ESP32/native modules?
Best regards,
Stefan
I then noticed that when I force the garbage collector between calls to my module, it started to produce the expected results. The algorithm uses a rather large struct to store its state (which is in bss).
I then tried to reproduce this using the examples, and corruptions/crashes do happen from time to time when playing with the features1 example:
Code: Select all
import features1
while True:
# Waste heap
open("test.txt", "w+")
# Access native python module
test = features1.access()
print(gc.mem_alloc())
Are there known issues with ESP32/native modules?
Best regards,
Stefan