# HG changeset patch # User William Astle # Date 1722717006 21600 # Node ID e49d24f4a9a5c7acb48ad23e92ff2980f5b9eee6 # Parent 40edb7de3857d78e58bf325b5b7990763c6d5674 Correct bug in the object file output code leading to stack corruption It turns out leaving a pointer to a stack allocated temporary in a persistent data structure is not conducive to correct program operation. Undo the export check setup in the object file output sequence so a pointer to stack allocated memory is not left hanging when the function returns. This seems to correct at least one mysterious crash bug, and possibly others. Thanks to Boisy Pitre for reporting the crash bug that led to this discovery, as well as a previous crash bug that likely has the same root cause. Additional thanks to Ciaran Anscomb whose debugger wielding wizardry revealed the exact location of this particular bit of unbrilliance. diff -r 40edb7de3857 -r e49d24f4a9a5 lwasm/output.c --- a/lwasm/output.c Fri Jul 12 23:02:57 2024 -0600 +++ b/lwasm/output.c Sat Aug 03 14:30:06 2024 -0600 @@ -1000,6 +1000,10 @@ buf[0] = (offset >> 8) & 0xff; buf[1] = offset & 0xff; writebytes(buf, 2, 1, of); + + // clean up after ourselves so other stuff doesn't explode + as -> cl = NULL; + as -> exportcheck = 0; } // flag end of incomplete references list