Repository navigation
AOT: fix localeCompare in hardened builds, and generators where loop polls do not fault - #1076
Conversation
The pointer to the known weights changes once the default collator is made, but it lay in a part of the instance that a hardened build makes read-only. It now has a writable part of its own.
Without one, a generator with a loop had no body to go on in after its consumer's loop had left it, and the program ended with "generator check failed".
There was a problem hiding this comment.
I reviewed this PR and did not find any bugs. Because it changes the hardened Instance layout and adds a new loop-poll form to straight code (exercised only where polls do not fault), a human look from someone who knows the AOT emitters would still be worthwhile.
What was reviewed:
- Every reader and writer of
knownLevel1Weights(B3 loads in AOTStringEmitterComparisons.cpp, the stub offset in AOTStubsStrings.cpp, the init in AOTInstance.cpp, the write in operationAOTStringLocaleCompare) is repointed to the new mutabledefaultCollatorpart;ducetLevel1Weightsstays in the written-oncecollationpart, and the 8-byte addition only shrinksunusedBelowWordsWrittenOnce. - The new non-faulting straight poll mirrors the walked
emitCompareAndCall: same sign test ontrapAwareSoftStackLimit(inverted), PollSlow's throws/terminates effects give the call a throw site throughStraightEmitter::callOperation, and listing PollSlow in themayFailToAllocatefalse-list matches the walked path's preserving stub (which also does not poll before returning) rather than skipping anything PollSlow would not do itself. - The straight path does not set
pollLeavesOwedError; that matches the pre-existing faulting straight form, which never used the owed-error poll offset either, since straight code does not consult sweep marks. - Not done here: running the three new .ir answer tests or the hardened x64/arm64 lanes; the author's qemu results are the only evidence for the non-faulting path.
Extended reasoning...
The change is confined to Source/JavaScriptCore/aot under ENABLE(AOT): it moves one pointer out of the written-once Instance region into a new mutable part, repoints its four users, makes the straight emitter always claim LoopHint with a compare-and-call form for non-faulting polls, shares a new branchIfStopRequest helper, and adds three answer tests. It touches no injection, auth or data-exposure surface, but it does alter the memory-protection layout of hardened builds and the termination/poll path of compiled loops. The code is internally consistent with the walked-code poll and with how PollSlow handles owed errors, and no findings were reported with a dry_streak exit. Deferring rather than approving because it is JIT codegen and instance-layout work in a compiler, the new path runs only on hardened arm64 and FreeBSD, and /Source/JavaScriptCore is covered by a CODEOWNERS entry.
|
Preview build of 2740b75: |
### What does this PR do? Moves `WEBKIT_VERSION` from `a8d825d8a049` to `0befb64c5f30`, the head of oven-sh/WebKit `main`. The release for that commit is published, with every asset name of the previous one. oven-sh/WebKit changes picked up: - Build lto-hardened-aot-no-webassembly for Linux arm64 (oven-sh/WebKit#1073) - [JSC] IsoCellSet::addSlow fences before storing a new bit set (oven-sh/WebKit#1075) - AOT: fix localeCompare in hardened builds, and generators where loop polls do not fault (oven-sh/WebKit#1076) ### How did you verify your code works? A debug build on Linux x64, with WebKit compiled from that commit, reports it in `process.versions.webkit`. It passes `webkit-prebuilt-url.test.ts`, `internal-module-blob.test.ts`, `bun-jsc.test.ts`, `test/js/bun/gc/` and 20 programs of `test/aot/parallel` that use `localeCompare` or loop over generators. The prebuilt libraries and hardened builds were not run locally. CI is their check. No test is added. --- _Generated by [Claude Code](https://claude.ai/code)_ Co-authored-by: Claude <[email protected]>
Fixes two crashes of ahead-of-time compiled programs.
localeComparesegfaults in hardened builds (x64 and arm64). The pointer to the known collation weights is set once the default collator exists, but it lay in the part of the instance that is made read-only at start. It now has a writable part of its own. The pointer to the table itself stays read-only."generator check failed" where loop polls do not fault (hardened arm64, FreeBSD). The straight emitter had no form for such a poll. So a generator with a loop had no body to go on in when a
returnthat was replaced during afor ofkept it. The poll is now a comparison and a call, as in walked code.What was run
Without LTO, arm64 under qemu with pointer authentication:
localeComparetest does so on hardened x64 too.test/aot/parallelon hardened arm64, 21 crashed before (13 and 8). None does now, and no other result changed.Generated by Claude Code