Skip to content

fix(ext/node): restore llhttp parser.data after execute to handle re-entrant calls - #33832

Merged
littledivy merged 2 commits into
denoland:mainfrom
divybot:claude/test-http-parser-multiple-execute
May 7, 2026
Merged

littledivy merged 2 commits into
denoland:mainfrom
divybot:claude/test-http-parser-multiple-execute

Conversation

@divybot

@divybot divybot commented May 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Enables test-http-parser-multiple-execute in node_compat suite.

Test plan

  • cargo test --test node_compat -- test-http-parser-multiple-execute

@fibibot fibibot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@littledivy
littledivy enabled auto-merge (squash) May 6, 2026 19:57

@fibibot fibibot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

auto-merge was automatically disabled May 6, 2026 21:17

Head branch was pushed to by a user without write access

@divybot
divybot force-pushed the claude/test-http-parser-multiple-execute branch from f6a568a to 03a1d7a Compare May 6, 2026 21:17
divybot and others added 2 commits May 7, 2026 02:50
…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>
@divybot
divybot force-pushed the claude/test-http-parser-multiple-execute branch from 03a1d7a to fb1f765 Compare May 6, 2026 21:21

@fibibot fibibot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 original fix(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 at 03a1d7ad on 2026-05-04).
  • fb1f765d — the comment-only addition (Save+restore for re-entrant execute() calls — see HTTPParser::execute.) at consume_read_callback and HTTPParser::execute sites that I approved earlier today at f6a568a9.

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.

@littledivy
littledivy enabled auto-merge (squash) May 7, 2026 03:56
@littledivy
littledivy merged commit 2b3e623 into denoland:main May 7, 2026
268 of 270 checks passed
littledivy added a commit to crowlKats/deno that referenced this pull request Jun 10, 2026
…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>
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.

3 participants