Repository navigation
fix(ext/node): restore llhttp parser.data after execute to handle re-entrant calls - #33832
Conversation
fibibot
left a comment
There was a problem hiding this comment.
LGTM. Surgical fix for an llhttp re-entrancy bug. Three call sites in ext/node/ops/llhttp/binding.rs all do the same parser.data = &ctx; llhttp_execute(); parser.data = null pattern — and previously each NULL-out would corrupt the outer ExecuteContext if the inner llhttp_execute was triggered re-entrantly by a JS callback (e.g. 'information' event handler firing on a 100 Continue response, calling back into execute() while an outer execute() is still running).
Substance walk
The fix pattern, applied symmetrically at three sites:
+let saved_data = inner.parser.data;
inner.parser.data = &mut ctx as *mut ExecuteContext as *mut std::ffi::c_void;
let err = unsafe { sys::llhttp_execute(...) };
-inner.parser.data = std::ptr::null_mut();
+inner.parser.data = saved_data;consume_read_callback(binding.rs:820, :830) ✓HTTPParser::execute(binding.rs:980, :992) — also has the explicit comment explaining the rationale ('information' event handler ... triggers another execute()). ✓HTTPParser::finish(binding.rs:1059, :1062) ✓
All three sites have the same shape, all use saved/restore via stack-local let saved_data = .... Correct.
Test enable (tests/node_compat/config.jsonc:1552): parallel/test-http-parser-multiple-execute.js — exactly the upstream Node test that exercises this re-entrancy pattern. ✓
CI
Required test node_compat debug threshold: linux-aarch64 (3/3), linux-x86_64 (3/3), macos-aarch64 (2/3 + 1 flake), windows-aarch64 (3/3), windows-x86_64 (3/3) — 14/15 of the relevant shards pass cleanly. The macos-aarch64 3/3 failure is Unable to download artifact(s): ENOTFOUND — the runner couldn't even fetch the build artifact, so no tests ran. Pure infra flake.
76 success, 22 in flight, 1 flake, 1 skipped. The release-mode shards already report green across 4 platforms.
Smaller observation (non-blocking)
The consume_read_callback site (:820) doesn't have the explanatory comment that HTTPParser::execute carries ("If a JS callback (e.g. the 'information' event handler for 100 Continue) triggers another execute()..."). For the third finish site, the comment is also absent. Adding a one-line // save+restore for re-entrant execute() calls — see HTTPParser::execute comment at the two missing sites would help future readers understand why the pattern is non-obvious. Pure documentation; not blocking.
fibibot
left a comment
There was a problem hiding this comment.
Re-confirming at new HEAD. The delta since my prior APPROVE at 03a1d7ad (2026-05-04) is f6a568a9 (fix(ext/node): add re-entrancy comments at consume_read_callback and finish sites) — a doc-only change adding two // Save+restore for re-entrant execute() calls — see HTTPParser::execute. comments at the relevant parser.data save/restore sites in ext/node/ops/llhttp/binding.rs.
No logic change. Substance is unchanged from my prior approve. Both consume_read_callback (line 820) and HTTPParser::execute (line 1060) now have the comment explaining why the manual save/restore is needed for re-entrant execute() calls — this is exactly the kind of non-obvious invariant that benefits from an inline note rather than relying on commit-message archaeology.
CI just started (2 of 135 checks reported). Substantive shards still pending, but the change is comment-only — risk is zero for the doc addition. The prior APPROVE remains valid; this is just acknowledgment that I've seen the comment-only update.
Head branch was pushed to by a user without write access
f6a568a to
03a1d7a
Compare
…entrant calls Enables tests/node_compat/runner/suite/test/parallel/test-http-parser-multiple-execute.js Co-authored-by: Divy Srivastava <me@littledivy.com>
…finish sites Adds a one-line cross-reference comment at the two llhttp call sites that were missing the explanation already present in HTTPParser::execute, as suggested by reviewer. Co-authored-by: Divy Srivastava <me@littledivy.com>
03a1d7a to
fb1f765
Compare
fibibot
left a comment
There was a problem hiding this comment.
Re-confirming after rebase. PR head moved from f6a568a9 (which I approved earlier today) to fb1f765d, and the only PR-specific commits in the new range are:
b7346a81— the originalfix(ext/node): restore llhttp parser.data after execute to handle re-entrant calls(re-applied at a new SHA in the rebase, content identical to what I approved at03a1d7adon 2026-05-04).fb1f765d— the comment-only addition (Save+restore for re-entrant execute() calls — see HTTPParser::execute.) atconsume_read_callbackandHTTPParser::executesites that I approved earlier today atf6a568a9.
All the other commits in the compare diff are merges of recent main work (including all the lazy-load conversions and module-hooks improvements I've reviewed today). No PR-specific substance change since my last approve.
CI: 92 success, 13 pending, 0 fail at this HEAD. The pending shards are slow ones; substance is unchanged so no risk.
…entrant calls (denoland#33832) ## Summary Enables `test-http-parser-multiple-execute` in node_compat suite. ## Test plan - [x] `cargo test --test node_compat -- test-http-parser-multiple-execute` --------- Co-authored-by: divybot <divybot@users.noreply.github.com> Co-authored-by: Divy Srivastava <me@littledivy.com>
Summary
Enables
test-http-parser-multiple-executein node_compat suite.Test plan
cargo test --test node_compat -- test-http-parser-multiple-execute