emcc: compiling with fsanitize=address and async function raises compile error

2 views
Skip to first unread message

leopatras

unread,
Jan 26, 2026, 12:09:09 PM (13 hours ago) Jan 26
to emscripten-discuss

I have an emscripten project which relies on the -sASYNCIFY features. Trying to compile it with fsanitize=address as additional argument to reveal problems fails because the functions wrapped with the EM_ASYNC_JS macro are then not seen by the compiler anymore.

I have a function addPersistentDirs exposed via the EM_ASYNC_JS macro

EM_ASYNC_JS(void,addPersistentDirsInt,(),...

and the compiler raises

error: undefined symbol: addPersistentDirsInt (referenced by root reference (e.g. compiled C/C++ code)) warning: To disable errors for undefined symbols use `-sERROR_ON_UNDEFINED_SYMBOLS=0` warning: _addPersistentDirsInt may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library Error: Aborting compilation due to previous errors at finalCombiner (file:///Users/leo/w/github/emsdk/upstream/emscripten/src/jsifier.mjs:889:13) at Module.runJSify (file:///Users/leo/w/github/emsdk/upstream/emscripten/src/jsifier.mjs:925:5) at file:///Users/leo/w/github/emsdk/upstream/emscripten/tools/compiler.mjs:108:17 emcc: error: '/Users/leo/w/github/emsdk/node/20.18.0_64bit/bin/node /Users/leo/w/github/emsdk/upstream/emscripten/tools/compiler.mjs -' failed (returned 1)

my compilation flags are

emcc  -O2 --pre-js pre.js -s MAIN_MODULE=1 -s FORCE_FILESYSTEM=1 -s EXPORT_ALL=1 -s ASSERTIONS=1 -s STACK_SIZE=200000 -s ASYNCIFY -s ASYNCIFY_STACK_SIZE=200000 -s MAXIMUM_MEMORY=4GB -s STACK_OVERFLOW_CHECK=2 -s EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -lidbfs.js  -lproxyfs.js -fsanitize=address main.c -o main.html

Is asyncify not supported when building with fsanitize=address ? I can't find a notion about that in the docs.

Compiling with -fsanitize=leak is fine btw.

Regards, Leo


Sam Clegg

unread,
Jan 26, 2026, 12:17:46 PM (13 hours ago) Jan 26
to emscripte...@googlegroups.com
Would you mind opening a bug report with reproduction instructions?

One thing to node is that EM_JS / EM_ASYNC_JS functions so have slightly different linkage to normal functions.   If you create a pass-through wrapper from `addPersistentDirsInt` as a normal C function does that fix the issue?

```
EM_ASYNC_JS(void,__addPersistentDirsInt,(),...);
void addPersistentDirsInt() {
  __addPersistentDirsInt()
}
```

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 visit https://groups.google.com/d/msgid/emscripten-discuss/4524cf56-c8c7-4ed4-bb2d-ecedae8164dcn%40googlegroups.com.

leopatras

unread,
Jan 26, 2026, 12:44:40 PM (13 hours ago) Jan 26
to emscripten-discuss
Thanks Sam, I tried your workaround ,but it just adds some underscores to the error

error: undefined symbol: __addPersistentDirsInt (referenced by root reference (e.g. compiled C/C++ code))

warning: To disable errors for undefined symbols use `-sERROR_ON_UNDEFINED_SYMBOLS=0`
warning: ___addPersistentDirsInt may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library

Error: Aborting compilation due to previous errors
    at finalCombiner (file:///Users/leo/w/github/emsdk/upstream/emscripten/src/jsifier.mjs:889:13)
    at Module.runJSify (file:///Users/leo/w/github/emsdk/upstream/emscripten/src/jsifier.mjs:925:5)
    at file:///Users/leo/w/github/emsdk/upstream/emscripten/tools/compiler.mjs:108:17
emcc: error: '/Users/leo/w/github/emsdk/node/20.18.0_64bit/bin/node /Users/leo/w/github/emsdk/upstream/emscripten/tools/compiler.mjs 
-' failed (returned 1)

As I have no clue what EM_ASYNC_JS expands to I don't know if the wrapped function has static or global scope.
Will add a bug report.
I added already a simple GitHub repo at https://github.com/leopatras/em_fsanitize_address

Regards, Leo

Reply all
Reply to author
Forward
0 new messages