TOPLLab / WARDuino

📟 A dynamic WebAssembly VM for embedded systems
https://topllab.github.io/WARDuino/
Mozilla Public License 2.0
73 stars 7 forks source link

Segmentation faults caused by incorrectly initializing struct fields #177

Open carllocos opened 1 year ago

carllocos commented 1 year ago

In issue https://github.com/TOPLLab/WARDuino/issues/119 we solved a segmentation problem that arises from not properly nullifying every field of the Module struct.

I experienced now the same problem but now caused by not properly nullifying the Table and memory struct. I noticed this issue since commit a19c7d9630c8114f0f6c0322054a899bc968088a (work on virtual addresses) and only via the CI (which was very frustrating to debug). Similarly to https://github.com/TOPLLab/WARDuino/issues/119, to fix this bug we need to give Table and memory instantiations default values on initialisation such as setting the pointers to nullptr.

Actually, we should do this for every possible struct to avoid potentially (painful) segmentation faults caused by not nullified structs fields.

I leave this issue as a remainder. The following structs should be considered: