pe_map: longjmp out of a mapped image fails fast (FAST_FAIL_INVALID_LONGJUMP_TARGET) when system CFG is on #1286
Open
opened 2026-11-24 07:00:41 +00:00 by archielcqp-a11y
·
11 comments
No Branch/Tag specified
main
codex/indirect-large-backed-views
codex/word3-preflight-check
codex/vertex-table-two-records
codex/live-index-alias
codex/copied-vertex-buffer-srv
codex/windows-stage-test-output
codex/preserve-live-srv-retirement
codex/share-render-target-tracking
codex/sgd5-negative-offset-fixture
coverage-dashboard
codex/mesh-loose-root
codex/mesh86-cache-padding
codex/xmem-scatter-preflight
codex/mesh-depth-ps
codex/indirect-dispatch-refresh
codex/compute-container-index
codex/startup-compute-formatted-load
codex/compute-indirect-producer
codex/compute-atomic-soffset
codex/mesh-dual-handoff
codex/startup-run-sh-watcher-control
codex/queue31-page-alias
codex/indexed-indirect-compute-root
codex/typed-buffer-view-metadata
codex/translated-indexed-address-alias
codex/fixed-mesh-create-result
codex/xmem-section-lease
codex/startup-slot86-mesh-cache
codex/restore-mesh-barrier-iteration
codex/translated-indirect-upload-index
codex/xapu-completion-opt-in
codex/translated-indexed-rect
codex/translated-indexed-indirect
codex/startup-mesh-lds-integration
codex/startup-console-ms24
codex/startup-slot57-mesh-request
codex/indirect-copy-provenance
codex/present-color-producer-trace
codex/compute-dispatch-binding-trace
codex/translated-indirect-table-buffers
codex/indirect-copy-provenance-base
codex/mix-half-literal-source
codex/translated-indirect-draw
codex/xmem-scatter-diagnostics
codex/slot148-recording-upload
codex/slot70-loading-art-verified
codex/command-list-upload-arena
codex/recover-failed-command-list
codex/startup-heap-timing-notes
codex/align-audio-input-timeline
codex/synthetic-depth-export-control
codex/startup-texture1d-on-windows
codex/1629-packed-position-fixture
codex/cpu-srv-refresh
codex/stream-root-srv-draw
codex/audio-mixer-timer
codex/startup-reload-published-shader
codex/priority-integrate-1284
codex/guest-sixteen-page-record
codex/aot-placed-dxr-batch
codex/guest-directory-selection
codex/gamesave-enumerate-read
codex/readme-archive-to-pixels
codex/pe-placed-view-draw
codex/archive-directory-gpu
codex/slot133-dxr-build
codex/materialize-placed-vertex-view
codex/dstorage-directory-offsets
codex/xg-nine-bc-copy
codex/xg-slot10-bc64-arrays
codex/dxr-guest-address-readback
codex/gpu-va-high-bits
codex/clarify-diagnostic-startup-scope
codex/xg-six-levels
codex/typed-derived-blend
codex/english-legal-text-progress
codex/address-bc-4ks
codex/dstorage-bounded-file-read
codex/wide-srv-offsets-menu
codex/startup-memory-srv
codex/bound-view-tail
codex/language-selector-readback
codex/setup-menu-progress
codex/cpu-plane-refresh
codex/startup-ubyte-vertex
codex/presenter-window-selection
codex/startup-uniform-buffer-lane
codex/intro-loop-timing
codex/static-clzero-loops
codex/document-rtx-intro
codex/startup-insertq
codex/nv12-startup-texture
codex/stream-stage-draw
codex/startup-null-uav-format
codex/startup-draw-capture
codex/shorten-windows-checks
codex/dstorage-rfc1950
codex/startup-dump-fence
codex/pr1135-review-base
codex/startup-stream-requests
codex/startup-chroma-view
codex/readme-graphics-pipeline-streams
codex/static-crt-free-tls
codex/arc-140t-rtx-5080-laptop-gpu-reports
codex/main-startup-progress-entry
codex/signed-dxil-catalogue
codex/reloc-free-preferred-base
codex/quad-dpp-bit-mask
codex/raw-srv-bounds
codex/rx9070-31044-hardware-report
codex/gpu-page-source-provenance
codex/runtime-placeholder-interior
codex/gpu-copy-queue-tile-order
codex/pe-pin-external-providers
codex/xmem-placeholder-reservations
codex/xmem-shared-physical-pages
codex/pe-package-startup
codex/xmem-tools-memory-query
codex/cpu-stack-output-import
codex/pe-load-security-cookie
codex/record-three-bvh-retests
codex/cpu-rbp-frame-anchor
codex/xmem-default-startup
codex/record-rtx-3050-ti-9597
codex/docs-readme-start-here
codex/check-compute-mad24-truncation
codex/docs-discord-community
codex/bound-rcx-branch-mutants
codex/rtx5060ti-bvh-62114
codex/837-neutral-readme-disclaimer
codex/record-rtx-3070-ti
codex/title-neutral-public-wording
codex/exe-shadow-frame-submissions
codex/exe-shadow-runtime-chain
codex/readme-polish
codex/gpu-coverage-nov23
codex/spirv-minlod
codex/shadow-shim-device
codex/exe-two-shadow-frames
codex/shim-dispatch-cleanup
codex/fix-spirv-cache-probe
codex/sampler-use
codex/ballot-bit-extract
codex/packed-fma-release
codex/cpu-packed-fma-o2
codex/publish-coverage-dashboard
codex/mesh-cbv-binding-order
codex/spirv-window-fixture
codex/ps-e32-float-uint
codex/ps-cbuffer-reads
codex/fixed-profile-rescan
codex/shim-compute-integration
codex/readme-visible-coverage
codex/readme-research-navigation
codex/integrate-pr-256
codex/indexed-mesh
codex/sampled-coverage
codex/first-ms
codex/dual-ps
codex/ps-attribute
codex/compute-first
codex/ps-export
codex/readme-research-status
codex/ps-layout
codex/blast-window
codex/chart-caption
codex/reviewer-roles
codex/blast-aot
codex/archive-program
codex/crc-stream-program
codex/exe-image-data-chain
codex/local-cpu-fixture-coverage
codex/exe-bound-frame-chain
codex/exe-mapped-comparison
codex/contribution-dependencies
codex/exe-entry-aot
codex/bink-frame-heap-integration
docs/hardware-seven-reports
codex/bink-custom-heap
codex/bink-heap-callers
codex/discussions-entry-points
codex/gpu-community-batch-64
codex/ffx-scratch-writers
codex/generic-project-documentation
codex/ffx-dispatch-rcas
codex/four-windows-gpu-reports
codex/title-neutral-project-wording
codex/community-coverage-provenance
codex/rcas-packed-texels
codex/community-gpu-retests
codex/community-build-and-gpu-reports
codex/ffx-provider-loop
codex/ffx-recurrent-views
codex/ffx-recurrent-resource
codex/amd-wave64-reports
codex/ffx-backend-slots
codex/upscaler-device-init
codex/ffx-context-lifecycle
codex/ffx-version-query
codex/ffx-provider-contract
codex/typed-object-callback
codex/cpu-ordinal-import
codex/chained-cpu-ranges
codex/cpu-import-call
codex/cpu-direct-call
codex/cpu-leaf-aot
codex/community-project-status
codex/script-state-path-replay
codex/script-state-evidence
codex/bc7-resident-tail
codex/bcpack-mip-tail
codex/bc7-texture-draw
codex/asset-ranges
codex/pixel-constants
codex/pixel-aot
codex/pre-exe-workloads
codex/root-signature-device-coverage
engineering/packed-bvh-leaves
engineering/bvh-build-and-update
engineering/intake-root-roundtrip
community/gpu-check-release
community/english-contributor-entry
gpu-check-v0.1.0
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
R0Y00/Xbox2Windows#1286
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by archielcqp-a11y on 2026-11-24T07:00:41Z.
Commit or build
f05369e(main); dev preset with OFFSCREEN_AGILITY_620_DIR and OFFSCREEN_WARP_DIR (the three tests do not depend on them)Reproduction
Expected behavior
The
pe_maprun of the "truncated" case matches the native and AOT runs: exit 2 and the tracealloc 8 / input 4 / input 0 / output 1 / free / completed 1.Observed behavior
All three tests fail in the
pe_maprun of the truncated case. The mapped child stops afterinput 0with exit0xC0000409(3221226505):Under
cdb -o(following the Python child):The native reader and the AOT EXE pass the same case; the "both", "first", "stale", "fail" and "leak" cases pass in all three runners, and
cpu_native_archive_reader(no blast) passes. With system CFG set to Off (same build, after a restart) all three tests pass.What the evidence points to
tests/cpu/archive/blast/blast.cleavesdecompthroughlongjmp(s->env, 1)when the input runs out (lines 81 and 165;setjmpat line 408). Only the truncated case reaches that path.tools/pe_map.cppmaps the image into private memory (VirtualAlloc(nullptr, SizeOfImage, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE), line 1084) and registers unwind data withRtlAddFunctionTable(line 1348), so the mapped blast code is notMEM_IMAGEand not in the loader's module list.longjmpunwind validates its target; a target inside private memory is rejected with subcode 0x26. Native and AOT runs load blast as a real image, so their target is accepted./guard:cf(blast_source.dll,archive_codec.dll,archive_texture_reader.exe), and neither the Python 3.12 nor the 3.14python.exesetsGUARD_CF, so the check follows the system CFG policy rather than a CFG-built host.Hypothesis, not tested: hosted CI passes on
windows-2025, where CFG is also on by default, so newer Windows builds may validate longjmp targets in private memory differently. A Windows 11 run with CFG on would separate the two.Possible directions, for discussion: map the image as an image section so it is
MEM_IMAGE, or record this as a knownpe_mapboundary and report the case as a named skip when the longjmp target check is enforced.This report was prepared with AI assistance.
Environment
Windows 10 22H2 build 19045.6466; Exploit protection system settings CFG On, bottom-up ASLR On, high-entropy ASLR On (defaults); MSVC 19.44.35230, Windows SDK 10.0.26100, CMake/Ninja from VS 2022 Build Tools; Python 3.14.3; cdb from Windows Kits 10. The three tests use no GPU-specific path for the failing case (archive_texture_gpu_warp also fails there on WARP 1.0.22).
Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-24T08:15:50Z.
Windows 11 data point for the hypothesis. It does not separate the two: Windows 11 rejects the target too.
Setup: Windows 11 Pro 26100.9168, MSVC 19.52, Python 3.12,
devpreset ate3193607. The system CFG setting on this machine is Off (Get-ProcessMitigation -System). I did not change it. Instead, I forced CFG on for the one mapped child process:CreateProcessWwithPROC_THREAD_ATTRIBUTE_MITIGATION_POLICY=PROCESS_CREATION_MITIGATION_POLICY_CONTROL_FLOW_GUARD_ALWAYS_ON(1 << 40), withALWAYS_OFF(2 << 40) as the control.Command: the mapped run of the truncated case:
python -B tests/cpu/archive_check.py --mapped pe_map.dll archive_reader.exe archive_codec.dll blast_source.dll, withFIRST_RECORD + SECOND_RECORD[:5]on stdin.output 1 / free / completed 1(expected)0xC0000409alloc 8 / input 4 / input 0This matches your Windows 10 result. Your run is under the system setting; mine is a per-process opt-in. On 26100, a longjmp target in
pe_map's private mapping is rejected once CFG is enforced for the process. It does not depend on the Windows 10 build.I could not read the fail-fast subcode: no cdb on this machine. That it is 0x26 here as well is an assumption.
One trap for anyone repeating this: the policy has to go on the base interpreter (
sys._base_executable, with the venv'ssite-packagesonPYTHONPATH).out/pe-env/Scripts/python.exeis a venv redirector that starts a second process, and the policy is not passed on. Through the redirector the case passes even with "always on".Not tested: why the hosted
windows-2025runner passes. Its effective CFG policy for the Python child is unknown to me.A detection for a named skip seems easy to add: the child can read
GetProcessMitigationPolicy(ProcessControlFlowGuardPolicy)→EnableControlFlowGuardbefore the truncated case. The per-process launcher above would then give CI a deterministic positive and negative run of that skip, without touching system settings. I can take either that or a first look at mapping the image asMEM_IMAGE, whichever you prefer.Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T10:22:26Z.
@legacy-code-archaeologist, are you already working on either option from your comment? If not, I'd like to take the root-cause side: make a
longjmpout of ape_map-mapped image pass the CFG long-jump target check (for example by registering the image'sGuardLongJumpTargetTabletargets, or by mapping it asMEM_IMAGE, whichever turns out to be the supported route), with your per-processALWAYS_ON/ALWAYS_OFFlauncher as the positive and negative control. The skip detection would stay yours if you want it. @R0Y00, happy to follow whichever split you prefer; I'll only reproduce locally until one of you answers.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T10:28:00Z.
Root cause, measured on this machine. No code change yet. The fix options at the end need your call.
Setup
ntdll.dll10.0.26100.9974. System CFG settingNOTSET.devbuild atb9c9f624.CreateProcessWon the base interpreter withPROC_THREAD_ATTRIBUTE_MITIGATION_POLICY, and the venvsite-packagesonPYTHONPATH. It runs the mapped truncated casearchive_check.py --mapped pe_map.dll archive_reader.exe archive_codec.dll blast_source.dllwithFIRST_RECORD + SECOND_RECORD[:5]on stdin.output 1 / free / completed 1ALWAYS_OFFoutput 1 / free / completed 1ALWAYS_ON0xC0000409alloc 8 / input 4 / input 0Where it fails
The
longjmpis inblast.c(blast_source.dll, mapped bype_maplike the reader). Its CRTlongjmpgoes throughRtlUnwindEx, which calls the exportedRtlGuardCheckLongJumpTarget. Reading that function in thisntdllbuild:ALWAYS_OFFruns.KiUserInvertedFunctionTable). If an image is found, it reads the image's load config. With no long-jump table present (GuardFlags & 0x10000), the target is accepted; otherwise the target is binary-searched inGuardLongJumpTargetTable.blast_source.dllhas no CF instrumentation, which is why the native run passes under CFG.RtlSetProtectedPolicy/SetProtectedPolicy, under GUID{4f6ae3a6-8b1b-4623-a293-294cd743bbd1}. A non-zero value accepts the target. Otherwise it callsRtlFailFast(38):0x26,FAST_FAIL_INVALID_LONGJUMP_TARGET.pe_mapmaps into private memory and registers.pdatawithRtlAddFunctionTable. That makes unwinding work, but it does not put the image into the inverted function table, so step 2 never finds it, and step 3 fails.Confirmation: in the
ALWAYS_ONchild, callingSetProtectedPolicy(&{4f6ae3a6-…}, 1, &old)before mapping makes the truncated case pass. The call returnsok=1, old=0, the exit is 2 and the trace is the expected one. Without that call the same child fails with0xC0000409. This was an experiment in a wrapper script only; nothing in the repository changed.Options
pe_map, or in the test child. This is the smallest change and it is measured to work. But that GUID is undocumented, Microsoft describesSetProtectedPolicyas "for use primarily by Windows, and not designed for external use", and the policy turns off long-jump target validation for every non-image address in the whole process, not just the mapped image. I would not do this by default. At most it would be an explicit opt-in for test runs.GetProcessMitigationPolicy(ProcessControlFlowGuardPolicy). It is honest about the limitation, but the mapped long-jump path then goes untested on CFG machines.LoadLibrary), whichpe_mapdeliberately avoids. Mapping withSEC_IMAGEalone would not register it either, as far as I can tell from step 2. I don't see a supported route here.longjmpimport to ape_mapreplacement that restores thejmp_bufwithoutRtlUnwindEx. This avoids the check, but it changes unwind semantics: no frame unwinding, so no C++ destructors. For C code like blast that is fine, but it would be wrong for a general image.My suggestion: option 2 for the tests now, with option 1 only if you explicitly want the mapped long-jump path exercised under CFG and accept the process-wide relaxation in test runs. Which do you want? I can implement either. I'll leave the skip side to @legacy-code-archaeologist if they still want it.
Limits
ntdllbuild. Older builds may differ in step 3.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-24T10:50:17Z.
@MasterDomino I haven't started either option and have no code for it, so the root-cause side is yours. I won't work on #1293 while you're on it. The launcher I used is just the
CreateProcessW+PROC_THREAD_ATTRIBUTE_MITIGATION_POLICYcall described above. If a Windows 11 26100 rerun of your fix would help (system CFG Off here, per-process ALWAYS_ON/OFF), ping me.Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T10:51:03Z.
Thanks @legacy-code-archaeologist, I'm taking #1293. I'll ping you for a 26100 rerun once there is a change. @R0Y00, I'll start coding once you pick between option 2 (named skip when CFG is enforced) and option 1 (explicit test-only opt-in to the long-jump protected policy) from my previous comment.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T14:04:29Z.
Please go ahead with option 2, the named capability skip. Leave the host’s CFG policy in force and check the effective policy in the process that executes the mapped fixture. Use the existing CTest skip convention only for the mapped case that requires
longjmpwhen CFG is confirmed active. Give the skip a specific diagnostic. Keep the native truncated-input check and unrelated mapped checks running. If reading the policy fails, report the failure explicitly.Please verify that the affected mapped case reports the named skip on a CFG-enforced host and still checks the expected error, cleanup, and exit when the effective policy permits it. Keep this issue open for actual mapped
longjmpsupport under CFG. The test-only protected-policy opt-in is declined.Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T14:59:32Z.
Claiming option 2: the mapped child reads its own effective CFG policy; only the mapped
longjmpcase reports a named capability skip (77) when CFG is active, a failed policy read fails explicitly, the native truncated check and the other mapped cases keep running. Refs only, so the issue stays open for real mappedlongjmpsupport. PR link to follow.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T15:03:05Z.
Option 2 PR: https://github.com/R0Y00/Xbox2Windows/pull/1614 (Refs, so this issue stays open). The mapped child checks its own effective CFG policy before mapping; only the marked longjmp case reports the named skip (77), a failed policy read fails explicitly, and everything else keeps running. Verified with the per-child CFG launcher (on → 77 + diagnostic; off → full error/cleanup/exit trace; unrelated mapped case under CFG → passes; unmarked → original fail-fast) and end to end for all three checks. @legacy-code-archaeologist, if your 26100 setup can put CFG on the test children, a rerun of the three CTests would be welcome.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-24T15:24:42Z.
@MasterDomino rerun of #1614 on Windows 11 Pro 26100.9168 (MSVC 19.52, Python 3.12,
devpreset at7c5dac78, i.e. with #1614 on main). System CFG on this machine is Off.CTest, with system CFG Off:
ctest --preset dev --no-tests=error -R '^(cpu_native_archive_blast|cpu_archive_texture_publication|cpu_archive_texture_gpu_warp)$'passes 3/3.CFG on the test children. I can't put CFG on the children that CTest itself starts: the policy attribute applies to the process I create, and the checks spawn their own children. So I ran the mapped child (
archive_check.py --mapped pe_map.dll archive_reader.exe archive_codec.dll blast_source.dll) directly. It runs on the base interpreter, withPROCESS_CREATION_MITIGATION_POLICY_CONTROL_FLOW_GUARD_ALWAYS_ONor_ALWAYS_OFF:X2W_MAPPED_LONGJMP_CASEskip: CFG is active in the pe_map runner; …completed 1(full alloc/input/output/free trace)0xC0000409input 0(the original fail-fast, unmarked)completed 2This matches your results: the skip fires only for the marked case with CFG active, and the error, cleanup and exit trace is intact with CFG off. One thing I noticed, not a problem in practice: the child skips whenever the marker is set, whatever its input. With CFG on, marker 1 and the "both" input, it also exits 77. That is fine as long as only the parent sets the marker, as
run_mapped_casedoes.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T15:24:57Z.
#1614 merged at
5bfd55a4. The three affected archive checks passed on my Windows Release run with zero skips. The author separately verified the named skip when CFG is active in the mapped child. This stays open for actual mapped longjmp support with CFG enforced.Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-29T14:49:10Z.
@MasterDomino, after #1614 are you still on the part that stays open here, actual mapped
longjmpsupport under CFG? If not, I'd like to take it. I'll wait for your answer, and for @R0Y00's on the design below, before writing code.Why the open options don't cover it. From your analysis above: option 1, the process-wide protected policy, is declined. Option 3 has no supported route, because only the loader fills the inverted function table. The plain version of option 4 skips frame unwinding, so it would be wrong for any image with
__finallyblocks or destructors betweensetjmpandlongjmp.Proposal (option 4 with a real unwind).
pe_mapbinds the mapped image'slongjmpimport to its own replacement.jmp_bufframe withRtlLookupFunctionEntry/RtlVirtualUnwind, which already works through theRtlAddFunctionTableregistration;EXCEPTION_UNWINDING | EXCEPTION_TARGET_UNWIND;jmp_bufcontext.RtlGuardCheckLongJumpTargetis never reached, and the host's CFG policy stays in force.RtlRestoreContextvalidates the target under CFG is the first thing I'll measure. If it does, I'll report that, and the issue stays open.Tests. Use the per-process
ALWAYS_ON/ALWAYS_OFFlauncher from @legacy-code-archaeologist's comment.__finallyblock and a nested handler frame betweensetjmpandlongjmp. In the mapped run, with CFG on and off, they run in the same order as in the native run.0xC0000409again;@R0Y00, is a
pe_mapunwinder limited to mapped frames acceptable as "actual support", or would you rather this stay a known boundary?Environment: Windows 11 build 26300, MSVC (VS 2022 / dev preset), Windows SDK 10.0.26100, Python 3.12. No GPU needed.
AI-assisted.