Skip to content

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
ehartford merged 2 commits into
mainfrom
audit-place-types-followup
Sep 22, 2026
Merged

ehartford merged 2 commits into
mainfrom
audit-place-types-followup

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Fix-forward for #1301, which merged before its battery: its place-type audit left test/behavior/behav_fn_abi_async.w red on main and had two defects of its own.

  1. Null-type guard (own commit): mir_place_projected_type reached LLVMGetTypeKind(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.ptr on a Box[Cell] local). Repro: a stage1 with 7f51e57's MirLower hunk reverted segfaults (rc=139, lldb frame #0 LLVMGetTypeKind, EXC_BAD_ACCESS at 0x8) in analyze r1280.w audit:codegen. Now returns unknown.
  2. Untyped projection is a violation. Fix #1280 (Box[T].ptr reads the payload's first field) and #1281 (element of a temporary skips D32 in argument/literal positions) #1301 skipped 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 reports place 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.
  3. Stated exclusion, Async lowering types an async call's result local as T while projecting Task.fiber_id (.f0) off it #1305. Run strict, the audit finds a separate real defect: the async lowering projects Task.fiber_id off call-result locals MIR types as the awaited T (base _28: Payload ... got-int-width=64 want-int-width=32, i.e. .f0 resolving to Payload.a). Fixing the local's type reaches into FIBER_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 fixture audit:all → violations=0; behav_fn_abi_async passes under the p7 harness (with out/stage/bin/with-stage2 aliased 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_arg pass. 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_free marshalling-fact violation on std.box programs), #1305.

Eric Hartford 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.
@ehartford
ehartford merged commit 9eddd3c into main Sep 22, 2026
0 of 5 checks passed
@ehartford
ehartford deleted the audit-place-types-followup branch September 22, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant