Skip to content

worker_threads: copy argv/execArgv for the worker thread instead of sharing the parent's StringImpls - #37140

Closed
robobun wants to merge 1 commit into
mainfrom
farm/ed6bb19f/worker-argv-cross-thread-atomstring
Closed

robobun wants to merge 1 commit into
mainfrom
farm/ed6bb19f/worker-argv-cross-thread-atomstring

worker_threads: copy argv/execArgv for the worker thread instead of s…

78e2f60
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Aug 7, 2026 in 20m 32s

Code review found 1 important issue

Found 3 candidates, confirmed 2. See review comments for details.

Details

Severity Count
🔴 Important 1
🟡 Nit 1
🟣 Pre-existing 0
Severity File:Line Issue
🔴 Important src/jsc/web_worker.rs:546-553 copy_args dereferences null WTFStringImpl (Symbol() in argv/execArgv crashes the parent)
🟡 Nit src/jsc/web_worker.rs:548-551 argv/execArgv lone surrogates are replaced with U+FFFD by the UTF-8 round-trip

Annotations

Check failure on line 553 in src/jsc/web_worker.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

copy_args dereferences null WTFStringImpl (Symbol() in argv/execArgv crashes the parent)

`copy_args` does `unsafe { &*s }.to_utf8()` on each `WTF::StringImpl*` with no null check, but a null impl is reachable: `coerceToIsolatedString` returns `String()` for `Symbol()` (no description), so `new Worker('x', {eval:true, argv:[Symbol()]})` (or `execArgv`) segfaults the **parent** thread inside `WebWorker__create`. The pre-PR consumers guarded this exact case (`!arg.is_null()` in `VirtualMachine.rs`, `if arg.is_null() { continue; }` in `jsc_hooks.rs`); both guards were removed and the co

Check warning on line 551 in src/jsc/web_worker.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

argv/execArgv lone surrogates are replaced with U+FFFD by the UTF-8 round-trip

nit: the UTF-8 round-trip here replaces lone surrogates with U+FFFD — `to_utf8()` on a 16-bit impl routes through `convert_utf16_to_utf8_append` → `decode_utf16_with_fffd`, so `new Worker(src, {argv:['\uD800foo']})` now sees `process.argv[2].charCodeAt(0) === 0xFFFD` where it was `0xD800` before (the old direct-wrap path preserved code units exactly). REVIEW.md's boundary-representation section calls out WTF-8 for lone surrogates specifically. Exotic trigger, so not blocking; consider storing `B