Repository navigation
audit:codegen place-type check: untyped projection is a violation, null-type guard, #1305 exclusion (fixes behav_fn_abi_async red from #1301) - #1307
Merged
Conversation
added 2 commits
September 22, 2026 09:56
… not a null type to index `mir_place_projected_type` overrides the walk's current LLVM type with `resolve_named_type(<base local's type name>)` when the base lowers to a pointer; for a transparent std Box that is 0, and the walk went on to `mir_resolve_field_index(0, ...)` — `LLVMGetTypeKind(null)`, EXC_BAD_ACCESS at address 0x8 (lldb, frame #0 `LLVMGetTypeKind`). Reached by the `audit:codegen` place-type check on the pre-#1280 IR (`_1.ptr` on a `Box[Cell]` local: a stage1 with the MirLower hunk of 7f51e57 reverted segfaults in `analyze r1280.w audit:codegen`, rc=139, instead of reporting). Return 0 (unknown) there; the audit turns unknown into a violation in the next commit.
…er-intrinsic places (#1305) The place-type audit landed in #1301 skipping places whose projection codegen could not type (`got == 0`). That is the #1280 shape itself: on the pre-fix IR the walk gives up on `Box[Cell].ptr` (`place 7 in main: projection could not be typed by codegen but its MIR type 1744 (*mut Cell) is kind 12`, from a stage1 with 7f51e57's MirLower hunk reverted), so the skip made the audit silent on the very bug it was added for. An untyped projection with a known MIR type is now a violation, and every violation names the base local and its type, the projection chain, and the integer widths, so the next report is a diagnosis rather than a kind number. Run strict on test/behavior/behav_fn_abi_async.w's fixture, the audit finds a real, separate defect: the async lowering projects `Task.fiber_id` (`.f0`) off a call-result local MIR types as the awaited T (`base _6: Unit`, `base _14: i64`, `base _28: Payload`, the last resolving to `Payload.a`, i64 for i32), and codegen's FIBER_* intrinsics agree with it only by convention (#1305, with the dump). That fixture asserts violations=0, so #1301 left it red on main. Fixing the local's type reaches into FIBER_AWAIT's result-type derivation and is not a one-line change; until #1305 the audit skips exactly the places that are an argument of an intrinsic call — a stated exclusion, cited in the code, not a weakened check. Verified on the fresh stage1: the fn_abi_async fixture and the fn_abi_callable / c_va_list fixtures audit `violations=0` on darwin_aarch64, linux_x86_64 and windows_x86_64; behav_fn_abi_async passes under the p7 harness; behav_box_ptr_field_read, behav_box_drop and behav_d32_temporary_element_arg pass. The pre-existing `with_free` marshalling-fact violation on std.box programs is #1300.
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.
Fix-forward for #1301, which merged before its battery: its place-type audit left
test/behavior/behav_fn_abi_async.wred on main and had two defects of its own.mir_place_projected_typereachedLLVMGetTypeKind(null)on the pre-Reading Box[T].ptr traps at run time (SIGTRAP) and fails codegen inside move fn drop (actual=i32 expected=ptr) #1280 IR (_1.ptron aBox[Cell]local). Repro: a stage1 with 7f51e57's MirLower hunk reverted segfaults (rc=139, lldb frame #0LLVMGetTypeKind, EXC_BAD_ACCESS at 0x8) inanalyze r1280.w audit:codegen. Now returns unknown.got == 0, which is the Reading Box[T].ptr traps at run time (SIGTRAP) and fails codegen inside move fn drop (actual=i32 expected=ptr) #1280 shape itself — with the strict rule the pre-fix IR reportsplace 7 in main: projection could not be typed by codegen but its MIR type 1744 (*mut Cell) is kind 12(proof that the audit now fires on the bug it was added for). Every violation also names the base local + type, the projection chain and integer widths.Task.fiber_idoff call-result locals MIR types as the awaitedT(base _28: Payload ... got-int-width=64 want-int-width=32, i.e..f0resolving toPayload.a). Fixing the local's type reaches intoFIBER_AWAIT's result-type derivation, so it is filed as Async lowering types an async call's result local as T while projecting Task.fiber_id (.f0) off it #1305 with the dump and the audit skips exactly the places that are an argument of an intrinsic call, cited in the code.Verified on the fresh stage1 (
:dev): fn_abi_async fixtureaudit:all→violations=0;behav_fn_abi_asyncpasses under the p7 harness (without/stage/bin/with-stage2aliased to stage1); fn_abi_callable and c_va_list fixtures audit clean on darwin_aarch64 / linux_x86_64 / windows_x86_64;behav_box_ptr_field_read,behav_box_drop,behav_d32_temporary_element_argpass. Battery not run — coordinator runs it first in the queue. No ABI/ownership change (analysis-only code plus a null guard on a type walk).Related: #1300 (pre-existing
with_freemarshalling-fact violation on std.box programs), #1305.