Skip to content

fix(sourcemap): honor the disable flag in the transpiler cache and fix its startup crash - #189

Merged
steipete merged 1 commit into
mainfrom
claude/fix-disable-source-maps-cache
Oct 17, 2026
Merged

steipete merged 1 commit into
mainfrom
claude/fix-disable-source-maps-cache

Conversation

@steipete

@steipete steipete commented Oct 17, 2026 •

Copy link
Copy Markdown

What does this PR do?

Fixes a startup crash when BUN_FEATURE_FLAG_DISABLE_SOURCE_MAPS=1 is used with the runtime transpiler cache. Two sequential imports of identical cacheable TypeScript modules reproduce it with a fresh cache: the first writes an empty map, and the second registers the empty buffer as an InternalSourceMap. Stack remapping then dereferences its dangling pointer at 0x11; unloading can also read the invalid header.

Validate map headers and bounds before registering their owned pointers. Include the disable flag in the cache features hash only when it is on, so flagged cache hits remain mapless and existing default hashes stay valid. Legacy empty-map entries under the default key are rejected and regenerated. The cache format/version and content-based filenames are unchanged; switching the flag replaces an entry through the existing feature-mismatch path.

Adapts empty-map validation and legacy recovery from oven-sh/bun#42412, with thanks to @robobun. That PR is open, and upstream main 017b2439a7a75c82c7a86a294badd8ef2fc30e28 still has both gaps. This change also fixes flag consistency while retaining caching with maps disabled.

How did you verify your code works?

  • All four new regression cases fail on the unpatched fork main and pass on this branch: fresh-cache duplicate import, both initial flag states with warm hits and transitions, and legacy empty-map recovery. Tests check stack positions, serialized map presence, distinct feature hashes, and unchanged old timestamps on actual cache hits.
  • Linux release builds pass before and after the fix. The native debugger confirms r12=0x1 at mov 0x10(%r12),%rbx in SavedSourceMap::get_with_content, followed by the source-remapping and Bun::formatStackTrace frames.
  • A default cache written by the unpatched binary is reused by the patched binary with identical bytes and unchanged modification time.
  • 171 targeted tests pass across the transpiler-cache, runtime-transpiler, source-map, node:module map, SIMD map and error-inspection suites, using the test runner's --expose-internals for its test-only module.
  • rust:check-all passes all 12 targets with the release build's generated code. Rustfmt and targeted Prettier pass. Independent Codex P2 autoreview is scoped-clean.
  • Native Linux and Darwin CI and all lint/format checks pass on 77c3b57350a14a60ab4cc8921e13200639b98375.

Validate map blobs before installing their owned pointers, and regenerate legacy mapless entries when maps are enabled. Include the disable flag only in the enabled flag state to preserve default cache hashes.

Adapts empty-map validation from oven-sh#42412.
@steipete
steipete marked this pull request as ready for review October 17, 2026 12:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T12:29:04.762313Z 77c3b57 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete
steipete merged commit 935bccf into main Oct 17, 2026
12 checks passed
@steipete
steipete deleted the claude/fix-disable-source-maps-cache branch October 17, 2026 12:29
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.

1 participant