WARDuino icon indicating copy to clipboard operation
WARDuino copied to clipboard

Segmentation faults caused by incorrectly initializing struct fields

Open carllocos opened this issue 2 years ago • 0 comments

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:

  • [ ] Options struct
  • [x] Memory (solved c20526f)
  • [x] Table (solved c20526f)
  • [ ] Frame
  • [ ] StackValue
  • [ ] Block
  • [ ] FuncPtr
  • [ ] Type

carllocos avatar May 17 '23 12:05 carllocos