Skip to content

test_pthread_join_and_asyncify fails on asan/lsan #21717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
aheejin opened this issue Apr 8, 2024 · 1 comment
Open

test_pthread_join_and_asyncify fails on asan/lsan #21717

aheejin opened this issue Apr 8, 2024 · 1 comment

Comments

@aheejin
Copy link
Member

aheejin commented Apr 8, 2024

asan.test_pthread_join_and_asyncify fails with the message

worker.js onmessage() captured an uncaught exception: RuntimeError: null function or function signature mismatch
RuntimeError: null function or function signature mismatch
    at test_pthread_join_and_asyncify.wasm.__asan::asan_thread_start(void*) (wasm://wasm/test_pthread_join_and_asyncify.wasm-00a319e6:wasm-function[571]:0x18984)
    at Object.invokeEntryPoint (/usr/local/google/home/aheejin/emscripten/out/test/test_pthread_join_and_asyncify.js:1465:37)
    at handleMessage (/usr/local/google/home/aheejin/emscripten/out/test/test_pthread_join_and_asyncify.worker.js:164:35)
    at MessagePort.<anonymous> (/usr/local/google/home/aheejin/emscripten/out/test/test_pthread_join_and_asyncify.worker.js:29:38)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:810:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)

lsan.test_pthread_join_and_asyncify fails in a similar way with only the function name (asan_thread_start) different.

This doesn't look related to #21663 because they fail without it too.

Our Test suite CI (https://ci.chromium.org/ui/p/emscripten-releases/builders/luci.emscripten-releases.ci/linux-test-suites) doesn't detect it because this test is only enabled with Node Canary and skipped in the CI.


I'm not very familiar with how JSPI and sanitizers work, but looking at the generated code, within asan_thread_start, there is a call_indirect. Here (type $3) is (param i32) (result i32)

   (call_indirect (type $3)
    (i32.load offset=12
     (local.get $1)
    )
    (i32.load offset=8
     (local.get $1)
    )
   )

which I think is supposed to call run_thread here:

pthread_create(&id, NULL, run_thread, NULL);

EMSCRIPTEN_KEEPALIVE void *run_thread(void *args) {

And run_thread's type is (param i32) (result i32).

But the actual function called by that call_indirect, which is in the elem section, is a function named $export$run_thread. And its signature is (param $susp externref) (param $0 i32) (result i32). (Note that there is an additional externref param)

I think this is the reason why it fails with the "signature mismatch" error. I'm not familiar with how JSPI works, so I'm not sure why run_thread is exported with a different signature.

cc @brendandahl

@brendandahl
Copy link
Collaborator

A lot of this will be changing with the new JSPI spec changes that don't require modification of the Wasm file. It's probably not worth looking into this issue for the time being, but revist when we update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants