Skip to content

Reproduce issue #13194 on the Wasm Workers API #18201

Draft
kleisauke wants to merge 4 commits intoemscripten-core:mainfrom
kleisauke:wasm-workers-stdio-locking
Draft

Reproduce issue #13194 on the Wasm Workers API #18201
kleisauke wants to merge 4 commits intoemscripten-core:mainfrom
kleisauke:wasm-workers-stdio-locking

Conversation

@kleisauke
Copy link
Collaborator

@kleisauke kleisauke commented Nov 14, 2022

@kleisauke kleisauke force-pushed the wasm-workers-stdio-locking branch from bdf0981 to f7af41c Compare March 14, 2026 10:27
@kleisauke
Copy link
Collaborator Author

It looks like PR #26489 is going to fix this.

@sbc100
Copy link
Collaborator

sbc100 commented Mar 18, 2026

Oh nice.. I'll see if can copy this test into my PR.

@kleisauke
Copy link
Collaborator Author

Great! Based on my comment in #18171 (comment), it seems this may also require setting libc.threaded / libc.need_locks, as well as the file locks for stdin, stdout and stderr when the first worker is created.

if (!libc.threaded) {
for (FILE *f=*__ofl_lock(); f; f=f->next)
init_file_lock(f);
__ofl_unlock();
init_file_lock(__stdin_used);
init_file_lock(__stdout_used);
init_file_lock(__stderr_used);
libc.threaded = 1;
}

// Set libc.need_locks before calling __pthread_create_js since
// by the time it returns the thread could be running and we
// want libc.need_locks to be set from the moment it starts.
if (!libc.threads_minus_1++) libc.need_locks = 1;

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

Successfully merging this pull request may close these issues.

2 participants