Repository navigation
fix(libc): return the fatal unwind error for an unknown personality on Windows - #9585
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
MarcZX10
left a comment
There was a problem hiding this comment.
The Windows guard addresses the reported invalid-address crash, and the Windows-only test registration is appropriately separate from the existing UNIX registration. The rerun conventions check on the current head passes, so the initial failing run is superseded.
The remaining required coordination is with #8087. It is open and changes Unwind.cpp, the same file this PR modifies. The description already gives a concrete composition plan if #8087 lands first, but the checklist still says Depends on: none, which does not record the required order. Please agree the order with #8087's author and update Depends on (or document the agreed reverse order and corresponding rebase). The repository rule requires overlap order to be agreed and listed in the checklist.
Hosted relinker, ASan, register-context and write-watch checks pass; the Linux and Windows product build jobs are skipped. The Windows test results in the description are author-reported; I did not run tests locally.
|
Merged Re-run on the merge (Windows 11, WinLibs GCC 15.2):
AI-assisted: yes |
|
Reviewed; verified the guard and the test wiring. On main, One nit: |
|
Thanks @fogydes, good catch. AI-assisted: yes |
There was a problem hiding this comment.
The fix now composes correctly with merged #8087: the Readable checks protect the shared ResolveImport path used by both personality and .sehgcc handler lookup. The zero-size VirtualQuery region case raised by the independent reviewer is also handled. I found no remaining behavior defect in the Windows guard, and the Windows red/green results are clearly reported by the author. One repository gate remains: 1. Test registration overlap: #6044 remains open and reorganizes the same libc/CMakeLists.txt exception-test block. Its patch moves the existing exception_personality registration while this PR adds a Windows registration for that test. The overlap workflow could not compare #6044 because it conflicts with main; the description notes the hunk count but does not record an agreed merge order with that PR's author or a Depends on edge. Please agree which change lands first and record the order in the checklist, then rebase accordingly. #8087 is already merged, so it no longer needs to be listed as a dependency. This head is also four commits behind current upstream/main; please update it after the overlap order is agreed. Checks on exact head a3fa95b4d75b7c3ed5299216d98e102dd6d3ef91: - git diff --check upstream/main...HEAD: passed. - python tools/check_conventions.py --base upstream/main --head HEAD: passed. - The latest hosted relinker matrix, ASan, register-context and write-watch checks pass. Hosted Linux/Windows product jobs are skipped. - The Windows-only exception_personality target is not available to run in this Linux workspace. The Windows test results and negative control in the PR description are author-reported; the independent review confirms the guard behavior and regression case. I am requesting changes for required overlap coordination and base freshness only, not a queue-based intake hold or a defect in the guarded read itself. It is fine to keep submitting PRs; maintainers will handle them in due course.
I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.
|
Thanks @MarcZX10 for the careful passes, and for confirming no remaining behaviour defect. On intake: we're keeping this open under the same reasoning as on #9379. It's a small fix/test with negative controls and no inferred title. If a maintainer asks on this PR to hold it, I'll convert it to a draft right away. I'll merge AI-assisted: yes |
|
Independent Windows run, as data only. Machine: Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Release. Head a3fa95b was merged onto
AI-assisted (Claude Code). |
|
Correction to my earlier review: please disregard its intake objection and request to defer. Given your contribution-count eligibility, a queue-based hold does not apply, and I am not asking you to infer a title need. The actionable review items are base freshness and the test-registration overlap. This head is 52 commits behind current |
|
I’ve noticed that my earlier request to hold this PR based on #5239 was unnecessary. It’s fine to keep submitting PRs; maintainers will handle them in due course. Please disregard that request. |
|
I noticed the CMake test-registration hunks in #9585 and #9775 share the insertion area with #10608, which adds the |
…n Windows CallPersonality followed a jmp [rip+disp] import thunk by reading the bytes at the personality address before checking it against the known personalities, so an unmapped personality faulted instead of returning _URC_FATAL_PHASE1_ERROR / _URC_FATAL_PHASE2_ERROR as it does on Linux. The thunk and its slot are now read only when VirtualQuery reports them committed and readable. exception_personality, which covers this, now runs on Windows too.
Readable advanced by each region's size, so a region reported with size 0 would never end the walk. It now counts as unreadable.
a3fa95b to
1d396a2
Compare
Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.
|
Checked the |
What
On Windows,
LibcUnwind::CallPersonalitychecks whether the personality address is ajmp [rip+disp]import thunk, and follows it, before comparing it to the known personalities. It does that by reading the bytes at the address. An unknown personality that isn't mapped therefore crashed the process with an access violation. On Linux the same input returns_URC_FATAL_PHASE1_ERROR/_URC_FATAL_PHASE2_ERROR.exception_personalitycovers exactly this case (CallPersonality(0x1000, ...), ExceptionPersonality.cpp:87-88), but it was registered only underif(UNIX). Built on Windows, it segfaulted at that line, and every earlier check passed.How:
Unwind.cpp(Windows only):ResolveImportuses aReadable(address, size)helper that walks theVirtualQueryregions and requires them to be committed, notPAGE_NOACCESS/PAGE_GUARD, and not execute-only. The 6 thunk bytes are read only if readable, and the slot they point to only if readable. Otherwise the address is compared as it is and falls through to the fatal result.libc/CMakeLists.txt: anif(WIN32)block registersexception_personality(libc link,configure_windows_unwind,PATHprepend), and theif(UNIX)registration is untouched. Moving the lines out ofif(UNIX)instead would have conflicted with fix(libc): build the host-facing libc code on macOS #4627, feat(aot): consolidate native ARM64 compiler, runtime and consumers #5021 and feat: macOS host support (Apple Silicon via Rosetta 2, Vulkan on MoltenVK) #8658, which edit the adjacentexception_runtimelines.Tested
exception_personalitypasses.Unwind.cppchange reverted, it segfaults.tools/check_conventions.pypasses.Overlap (
tools/pr_overlap.py --branchplusgit merge-tree):static Word ResolveImport(Word), whichVirtualUnwindalso calls for.sehgcchandlers. Since the merge, the twoReadablechecks live inResolveImport, which returns the address unchanged when it is not readable, so they cover both callers.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)