Emscripten can't find its own dlfree?

33 views
Skip to first unread message

Walt Tucker

unread,
Feb 26, 2020, 1:17:55 PM2/26/20
to emscripten-discuss
With the llvm-wasm backend, I'm hitting a couple of instances where when trying to free some memory with free(), emscripten is aborting at runtime saying that dlfree() is undefined. From what I can tell, memory functions are transformed to use the dlmalloc implementation that emscripten uses and builds. When looking at the compiled library in my .emscripten_cache (libdlmalloc-mt-debug.a), I see those functions defined in the text section as expected(dlfree, dlmalloc, etc). 
I'm curious when this transformation happens (it's not during preprocessing), and if it's missing some other step. The reason I wonder about that is because I also see references to emscripten_builtin_malloc and emscripten_builtin_free.

The error:
worker.js onmessage() captured an uncaught exception: RuntimeError: abort(undefined) at jsStackTrace
stackTrace @xxx
abort @xxx
_abort @xxx
dlfree @xxx   (our call to free)
........

Has anyone seen this before, and is this something I'm doing wrong when compiling/linking? This is using emscripten 1.39.7.

Sam Clegg

unread,
Feb 26, 2020, 6:42:29 PM2/26/20
to emscripte...@googlegroups.com

It looks like it does successfully find dlfree (since this abort comes from within a call to dlfree, no?).   Assuming the `dlfree` in the callstack is a wasm frame then the callstack looks normal.  What makes you think it can't find dlfree?  The error message `abort(undefined)` could mean a number of things but one is that `dlfree` itself detected some issue and called abort (or indirectly via assert).

cheers,
sam



--
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 emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/40fe2228-69d1-47a7-94a3-9ddb455e045b%40googlegroups.com.

Shachar Langbeheim

unread,
Feb 26, 2020, 11:01:08 PM2/26/20
to emscripten-discuss
I've seen similar issues when separate parts of the code were compiled with different versions of emscripten.

--

Walt Tucker

unread,
Mar 4, 2020, 1:43:19 PM3/4/20
to emscripten-discuss


The error message `abort(undefined)` could mean a number of things but one is that `dlfree` itself detected some issue and called abort (or indirectly via assert).


That's exactly what it was. I was thrown for a loop with the "undefined" because I've hit multiple cases of having missing functions and seeing a similar error. Accidentally attempting to free something that wasn't previously allocated tripped an abort here: https://github.com/emscripten-core/emscripten/blob/master/system/lib/dlmalloc.c#L4867 
Sorry for the misunderstanding, and thanks for the help.
Reply all
Reply to author
Forward
0 new messages