Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions system/lib/pthread/proxying.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,11 @@ void emscripten_proxy_finish(em_proxying_ctx* ctx) {
pthread_mutex_lock(&ctx->sync.mutex);
ctx->sync.state = DONE;
remove_active_ctx(ctx);
pthread_mutex_unlock(&ctx->sync.mutex);
// Signal must come before unlock to avoid emscripten_proxy_sync_with ctx
// seeing the state as DONE and freeing the ctx before we call unlock.
// See https://github.com/emscripten-core/emscripten/pull/26582
pthread_cond_signal(&ctx->sync.cond);
pthread_mutex_unlock(&ctx->sync.mutex);
} else {
// Schedule the callback on the caller thread. If the caller thread has
// already died or dies before the callback is executed, then at least make
Expand All @@ -365,8 +368,9 @@ static void cancel_ctx(void* arg) {
if (ctx->kind == SYNC) {
pthread_mutex_lock(&ctx->sync.mutex);
ctx->sync.state = CANCELED;
pthread_mutex_unlock(&ctx->sync.mutex);
// Signal must be first, see comment in emscripten_proxy_finish.
pthread_cond_signal(&ctx->sync.cond);
pthread_mutex_unlock(&ctx->sync.mutex);
} else {
if (ctx->cb.cancel == NULL ||
!do_proxy(ctx->cb.queue,
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_minimal_pthreads.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"a.out.js": 7363,
"a.out.js.gz": 3604,
"a.out.nodebug.wasm": 19046,
"a.out.nodebug.wasm.gz": 8822,
"a.out.nodebug.wasm.gz": 8821,
"total": 26409,
"total_gz": 12426,
"total_gz": 12425,
"sent": [
"a (memory)",
"b (exit)",
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_minimal_pthreads_memgrowth.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"a.out.js": 7765,
"a.out.js.gz": 3810,
"a.out.nodebug.wasm": 19047,
"a.out.nodebug.wasm.gz": 8823,
"a.out.nodebug.wasm.gz": 8822,
"total": 26812,
"total_gz": 12633,
"total_gz": 12632,
"sent": [
"a (memory)",
"b (exit)",
Expand Down
Loading