Skip to content

Commit 160ba89

Browse files
VirtualTimkripken
authored andcommitted
Show a clear assertion failure if thread initialization fails (#8481)
Without this PR we'dt call _emscripten_futex_wake which is not set up, and fail there, hiding the real error.
1 parent 49d7717 commit 160ba89

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/worker.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ this.onmessage = function(e) {
203203
} else {
204204
Atomics.store(HEAPU32, (threadInfoStruct + 4 /*C_STRUCTS.pthread.threadExitCode*/ ) >> 2, (e instanceof {{{ makeAsmGlobalAccessInPthread('ExitStatus') }}}) ? e.status : -2 /*A custom entry specific to Emscripten denoting that the thread crashed.*/);
205205
Atomics.store(HEAPU32, (threadInfoStruct + 0 /*C_STRUCTS.pthread.threadStatus*/ ) >> 2, 1); // Mark the thread as no longer running.
206+
#if ASSERTIONS
207+
if (typeof({{{ makeAsmGlobalAccessInPthread('_emscripten_futex_wake') }}}) !== "function") {
208+
err("Thread Initialisation failed.");
209+
throw e;
210+
}
211+
#endif
206212
{{{ makeAsmGlobalAccessInPthread('_emscripten_futex_wake') }}}(threadInfoStruct + 0 /*C_STRUCTS.pthread.threadStatus*/, 0x7FFFFFFF/*INT_MAX*/); // Wake all threads waiting on this thread to finish.
207213
if (!(e instanceof {{{ makeAsmGlobalAccessInPthread('ExitStatus') }}})) throw e;
208214
}

0 commit comments

Comments
 (0)