← Back to Pull requests

zlib,url: avoid flattening strings in value-returning fast API calls #67536

Closed
unknown closed this pull request without merging on Nov 29, 2026 13:26 UTC
View on GitHub
unknown unknown commented on Nov 17, 2026 05:50 UTC
Author

zlib.crc32(), zlib.crc32c() (string input) and URL.canParse() can abort the process with:

abort: Lazy deopt after a fast API call with return value is unsupported

This is the same crash as #66870, which #67136 fixed for Buffer.byteLength(). The fast callbacks of these APIs flatten or convert their string argument (Utf8Value / String::ValueView, and ToString() in canParse). Flattening a large non-flat string allocates; if that allocation triggers a full GC that invalidates the optimized caller (for example by clearing a weakly embedded map), V8 has to lazily deoptimize the caller once the fast call returns. V8 does not support that for fast calls that return a value and runs Builtin::kAbort instead (crbug.com/418936518, see FastApiCallReducerAssembler::ReduceFastApiCall in deps/v8/src/compiler/js-call-reducer.cc).

Changes:

  • zlib: string input to crc32()/crc32c() now goes through a regular binding. The fast bindings only take ArrayBufferViews, which are read without allocating.

  • url: the canParse() fast path now takes a sequential one-byte string (FastOneByteString), which V8 passes without allocating, and returns -1 for anything else so JavaScript calls the regular binding, the same approach as #67136. ToString() is no longer called inside a fast callback.

  • test: test/parallel/test-fast-api-calls-gc-lazy-deopt.js optimizes a caller of each API, drops the only object with a weakly embedded map, and calls it with non-flat old-space strings so that a full GC runs while the string is read. It aborts on v27.0.0-alpha.0.1.0 and passes with this change.
  • I reproduced the abort on 25.0.0 to 26.13.1 and on v27.0.0-alpha.0.1.0 (crc32 and canParse; byteLength is already fixed there by #67136).

    One note on URL.canParse(): the interpreter only ever sees the slow callback's -1, so the first optimized call at a call site deopts once (insufficient feedback for the result === 1 compare) and is then re-optimized.

    canParse() gets faster for ASCII input, since the fast path no longer converts or copies the string. crc32()/crc32c() are unchanged for buffers and large strings; very short string inputs may be somewhat slower because strings no longer take the fast call. These numbers come from benchmark/compare.js with 8 runs on a laptop, so small differences are noise; a benchmark CI run would give firmer numbers.

    <img width="1228" height="649" alt="image" src="https://github.com/user-attachments/assets/4e5d1678-d95d-4cad-bab5-1b23fe7a550e" />

    permission.has() uses the same pattern (Utf8Value in a value-returning fast callback), but I have not reproduced the crash there, so it is not part of this PR.

    AI disclosure: I used a coding agent to help with the root-cause analysis and the initial patch. I reviewed the change, reproduced the crash on the versions above, checked that the new test fails without the fix, and ran make lint, make format-cpp, and the zlib, url and Buffer.byteLength tests (parallel/test-zlib, parallel/test-whatwg-url, parallel/test-url, parallel/test-buffer-bytelength). I have not run the full make -j4 test.

    Refs: https://github.com/nodejs/node/issues/66870
    Refs: https://github.com/nodejs/node/pull/67136

    Diff: 408 lines (+306 / -102) across 5 files Reviewer: anonrig Review duration: 17736m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.45) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 408 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.360
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #67536"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.8% (MEDIUM) · Higher = larger blast radius
    44.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.4% · Safe to merge
    19.4%
    Repository