Repository navigation
The JIT cache no longer crashes a run that compiles two or more modules - #549
Merged
Merged
Conversation
The JIT cache compiles each module in an MLIRContext of its own, but the built-in types (i32, f32, Opaque, ...) were kept in a function-local static map, made once in the first module's context. Every later module in the run got types from a context already destroyed: 0xC0000005 in the compiler. The default library's declarations name such types, so every program importing a .ts module crashed (native_ts_graphics finding 7). The map is now a member of MLIRGenImpl, made on first use per module. Regression test test-jit-cache-embedded-types runs from an empty cache every time (jit-cache-empty.cmake); a test-runner test keeps its cache beside the source and compiles nothing from its second run on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 11, 2026
ASDAlexander77
added a commit
that referenced
this pull request
Oct 12, 2026
…558) Every repro in docs/bugs passes on main, or fails as TypeScript does: the native_ts_graphics findings were fixed by #535-#544 and #549 (the `let s = 0` one by design, with a warning since #544), testFallThrough, generic_in_generic and array_of_ifaces_cast by #538, #542 and #543, and bug14 and bug21 aren't valid TypeScript. Each fix has its regression test in tslang/test/tester, and the findings document is in the history and in those PRs, so the folder goes. Its interop notes stay, in docs/c-cpp-header-import.md: a `string` returned by a C function is its `char*`, not a copy; `number` is a `double`; and a nullable `Ref<T>` field is spelled `Ref<T> | null`. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes native_ts_graphics finding 7 (
docs/bugs/native-ts-graphics-findings.md, filed in #548): with the JIT cache on (the default), a program importing a.tsmodule crashed the compiler with 0xC0000005 before running, even from an empty cache.Cause: the cache compiles each module in an MLIRContext of its own.
getEmbeddedTypeBuiltins/getEmbeddedTypeNoBuiltinskept the built-in types (i32,f32,Opaque, ...) in a function-localstatic llvm::StringMap<mlir::Type>, made once in the first module's context. Every later module in the run got types from a context destroyed by then (the crash is theNoneTypeTypeID compare inisGenericParameterson a freed type). The default library's declarations name such types, so every import crashed with it; without it (--no-default-lib, as the suite runs) only a module naming one itself did.Fix: the map is a member of
MLIRGenImpl, made on first use, so it lives exactly as long as one module's generation.lookupinstead ofoperator[]: same null type for an unknown name, without inserting it.Test:
test-jit-cache-embedded-types(jit-cache/embedded_types.tsimportingembedded_types_module.ts, both namingi32/i64/f32), run throughjit-cache-empty.cmake, which empties the cache first: a test-runner test keeps its cache beside the source and compiles nothing from its second run on. It crashes 3/3 on main and passes with the fix.Verified on Release:
docs/bugs/ntg_jit_cache_import.tswith the default library, from an empty cache:42,doneon the first run (crashed before).jit-cache/imports_diamond.tswith the default library, empty cache: passes (crashed before).ctest -j 16 -C Release: 100% of 3977 passed.🤖 Generated with Claude Code