I imagine there is some issue with how you are writing your data the wasm memory, What is the `Module.HEAP8.set(uint8array, uint8array.length)` supposed to be doing?
You need to be very careful when writing the wasm memory that you don't overwrite anything in the heap, stack or static data regions. In general you should only write the regions that have been allocated with malloc first, and then free them when you are done. `Module.HEAP8.set(uint8array, uint8array.length)`` looks a little suspicious to me because because the second argument I believe is that offset, which means you are writing uint8array at offset uint8array.length .. which seems like something you certainly wouldn't want to do. But I could be misunderstanding. Regarding the crash in wasm-emscripten-finalize, that looks like it must be a bug, if you can create a repro case a bug would be very welcome. On Thu, Jun 18, 2020 at 3:06 AM lukewarmtea137 <[email protected]> wrote: > Hi thanks for the reply, > `-fsanitize=address` printed that I should use `-s ALLOW_MEMORY_GROWTH=1`, > which looked like it cleared all the issues. > > However when I called my function `decodeOggPage`, this is printed in the > console: > Assertion failed: Cannot call unknown function decodeOggPage, make sure > it is exported > > So I added `-s EXPORTED_FUNCTIONS="['_decodeOggPage']"` as another option, > though this caused the compilation to fail with this error: > [parse exception: attempted pop from empty stack / beyond block start > boundary at 20550 (at 0:20550)] > Fatal: error in parsing input > emcc: error: '/home/user/emsdk/upstream/bin/wasm-emscripten-finalize > --detect-features --global-base=33554432 --check-stack-overflow > /tmp/emscripten_temp_ugi93if_/a.out.wasm -o > /tmp/emscripten_temp_ugi93if_/a.out.wasm.o.wasm' failed (1) > > For reference, this is the command I was using for compilation: > emcc main.c -Iinclude/opus -lopus -L$HOME/emscripten_opus/lib -s > EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap", "ccall"]' -s > ALLOW_MEMORY_GROWTH=1 -fsanitize=address -s > EXPORTED_FUNCTIONS="['_decodeOggPage']" > > Additionally it appeared that if I removed `-fsanitize=address`, then the > second time I called the following `Module.HEAP8.set(uint8array, > uint8array.length)` (in the first time the offset was 0) it appeared to > cause a segfault also, is this related? > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/emscripten-discuss/987bf27d-fca9-4ad7-9719-0c193f1d756fo%40googlegroups.com > <https://groups.google.com/d/msgid/emscripten-discuss/987bf27d-fca9-4ad7-9719-0c193f1d756fo%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAL_va2_wj9G5cP8%2B3ewd015WncBYJzeH1w1YKjxLEqc7Sr_qgA%40mail.gmail.com.
