Repository navigation
Windows: win64 indirect-aggregate call-arg ABI fix (#798 codegen prerequisite) - #812
Merged
Merged
Conversation
ropoctl
force-pushed
the
windows-regex-fnarg-abi-798
branch
from
August 17, 2026 02:27
f91ca09 to
39646a0
Compare
ropoctl
force-pushed
the
windows-regex-fnarg-abi-798
branch
2 times, most recently
from
August 17, 2026 04:03
29a3e5c to
c841f15
Compare
… not arg (#798) The win64 internal-ABI indirect-aggregate call-argument path decided whether to spill an argument to an alloca and pass its address by inspecting the ARGUMENT's sema type. For a bare function item passed to a `*const fn(...)` parameter that is wrong: the argument's type is TY_FN, which mir_sema_type_to_llvm lowers to a fat {ptr,ptr} closure (16 bytes), so internal_abi_needs_indirect_param said "indirect" and the caller spilled the fat value and passed its stack address. The callee, however, declares a thin `ptr` parameter and `call`s through it directly — executing stack data. On native win64 that is a 0xC0000005 access violation, which is the regex crash (#798): pcre2_general_context_create_8 takes `*const fn` malloc/free pointers and regex_runtime.w passes bare fns. Fix: mirror the CALLEE's own ABI decision, per the FnAbi doctrine — one ABI decision per signature, computed from the parameter and read by both the callee prologue and this call site. Key the aggregate LLVM type on the callee's declared param sema type (expected_sema_ty, already computed from the signature above), which lowers a `*const fn` param to a thin `ptr` (not indirect → no spill, falls through to normal pointer passing) and a genuine by-value aggregate param to its struct type (indirect → spill, unchanged). Fall back to the argument's type only for an unsignatured indirect closure call, where no callee signature exists. Proven at IR level for the minimal /tmp/fnptr.w repro and all three rt/regex_runtime.w create_8 call sites. Un-skip of the #798 regex tests and the windows regex-runtime rebuild follow once the isolation battery (build/fixpoint/audits/test/drop-audit/move-audit) blesses it.
ropoctl
force-pushed
the
windows-regex-fnarg-abi-798
branch
from
August 17, 2026 05:18
c841f15 to
7ca6952
Compare
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.
Windows: win64 indirect-aggregate call-arg ABI fix (#798)
Lands the codegen fix for the native-Windows
0xC0000005fault that anyregex literal triggered.
Root cause
The win64 internal-ABI indirect-aggregate call path decided the aggregate
LLVM type from the argument's sema type rather than the callee's
declared parameter type. A bare
fnitem lowers to a fat{ptr, ptr}16-byte closure; when passed to a parameter declared
*const fn(a thinpointer), the caller spilled the fat closure to a stack alloca and passed
its address where the callee reads a thin function pointer. The callee
then called through a pointer into stack data — faulting
0xC0000005themoment any regex literal reached
pcre2_general_context_create_8.Fix (
src/CodegenDispatch.w)Key the indirect-aggregate decision on the callee's declared parameter
type (
expected_sema_ty), falling back to the argument's sema type onlyfor unsignatured indirect closure calls. A
*const fnparam now passes aplain pointer and no longer spills. This follows the
FnAbisingle-sourcedoctrine: the passing shape comes from the signature, computed once, read
at the call site.
Verified natively on the Windows VM: the six regex exes, linked against a
regex_runtime.orebuilt with this fix, printok(RC=0).Why the 6 regex behavior tests stay
skip-windows: #798The faulting call sites live in the compiler-internal
rt/regex_runtime.w(
pcre2_general_context_create_8), whichbuild.wcompiles into theembedded
regex_runtime.ousing the fetched seed compiler — whichpredates this fix. So the linked runtime object still contains the buggy
lowering until the seed is refreshed with a compiler that carries this
fix. Un-skipping the six tests is therefore blocked on a reseed (or a
build.wchange that builds the runtime objects with the freshly-stagedcompiler instead of the seed) — tracked in #798 / #60. Un-skipping here
would red the battery on a fix that is present in source but absent from
the embedded runtime.
This PR lands the correct codegen prerequisite; the un-skip follows once
the runtime object is rebuilt with it.