Repository navigation
Description
Severity: P0 — accepted-but-unsound program (data race reachable in the checked Tier-0 subset).
The smallest .hy program that demonstrates it
// callee_store_share.hy — commit e2a5f7d5eb90becb210df274765adfa50c99b21b (main, 2026-10-17)
// hyb check callee_store_share.hy → OK (0 diagnostics)
// hyb build callee_store_share.hy -o callee_store_share && ./callee_store_share
// → fatal error: concurrent map writes (5/5 runs, exit 2)
fn set(dst []map[string]int, v map[string]int) {
dst[0] = v
}
fn worker(m map[string]int) {
for i in 1..=200000 {
m["task"]++
}
}
fn main() {
shared := map[string]int{}
dst := []map[string]int{map[string]int{}}
set(dst, shared)
task worker(move shared)
for i in 1..=200000 {
dst[0]["main"]++
}
}Environment: Linux x86_64, hyb built from e2a5f7d5eb90becb210df274765adfa50c99b21b
with cargo build --release (Rust pinned 1.93.1), emitted Go built with go1.26.8.
What the checker should say
HYB-E3003 at the parent's dst[0]["main"]++: the helper's assignment dst[0] = v makes
dst[0] a live alias of shared in the caller, so after task worker(move shared) the
parent may not keep writing through it (O5.2, "every live alias … is frozen").
The same program with the store written directly in main is correctly rejected:
dst[0] = shared // in main
task worker(move shared)
dst[0]["main"]++ // HYB-E3003: write through a live alias of a moved valueWhat it actually said
$ hyb check callee_store_share.hy
callee_store_share.hy: OK (0 diagnostics)
At run time dst[0] and shared are the same map after the call; the two tasks write it
concurrently and the Go runtime reports fatal error: concurrent map writes in 5/5
runs (exit 2). Two controls with the same binary: the direct-store form rejects with
HYB-E3003; a helper taking the same two arguments but not assigning ({ _ = v }) is
accepted — so the store inside the helper frame is the relevant difference.
Anything else
Rule: O5.2 (freeze-after-move); GUARANTEES row 6 ("a moved value cannot be used by the
sender afterwards"). The program is pure Tier-0: no managed, const, pointers, closures,
imports, or foreign calls.
Mechanism: FnState.may_share is populated from the analysed function's own assignments
(loans.rs::process_assign); the Resolved::Fn branch of process_call records
copy/delete/const effects and A3 loan events across a callee (check_a3_call_conflict,
#111/#117), but has no may-share effect for "callee stores parameter j into a place rooted
at parameter i". The call site therefore records no edge between the caller's dst and
shared, and mark_move cannot freeze the helper-created alias.
Related, not duplicate (checked against the open+closed issue/PR texts): #92/#93 and
#296/#398 are the same-function field/index store gap (the direct-store control here now
rejects); #73 and #120 are call-result aliasing (the value must be returned and bound);
#111/#117 are the A3 loan-window precedent across a callee frame; #131 covers pointer
borrows; #75/#410 cover moving a may-share peer of a parameter. None describes a helper
store that retains one argument through another.
First report of this mechanism. Credit: the GitHub account filing this issue.
Activity
hy-check: rustfmt the limitlessprojects#455 helper-store additions (n…
dezzy-music commentedon Oct 17, 2026
I'm on it. Senior systems & compiler engineer here — reproduced the helper-frame out-param store race locally. Working on the interprocedural parameter store aliasing tracking in \process_call\ right now. Will deliver the complete fix and regression test today.
dezzy-music commentedon Oct 17, 2026
Submitted verified fix in PR #470.
Cause
In
loans.rs,process_callhandledcopy,delete, and A3 loan conflicts, but did not analyze interprocedural interior stores between parameters (e.g.dst[0] = v). Consequently,st.may_sharenever recorded an edge between caller arguments when a callee stored one parameter into another. Whensharedwas moved,mark_movetraversed only existing share group peers, leavingdstunfrozen in the caller frame and enabling concurrent writes at runtime.Fix
compiler/crates/hy-check/src/loans.rs:fn_stores_param_into_paramtraversing statement bodies, block scopes, local aliases, and nested callee frames to identify interior stores between parameters (t.root() == dst_param && !t.is_ident(dst_param)where RHS reachessrc_param).record_callee_stores_may_shareandrecord_method_stores_may_shareto establish bidirectionalst.share_edge(d, s)between caller argument roots.compiler/crates/hy-check/src/lib.rs:helper_frame_out_param_store_freezes_caller_alias_issue_455testing both the P0 reproducer (rejectsHYB-E3003) and a positive control (no_storehelper without interior assignment, accepts cleanly with 0 diagnostics).fix(hy-check): track helper-frame out-param and receiver stores (limi…
gelismarvel commentedon Oct 17, 2026
Fixes #455
Summary
When a helper function or user-defined method stores a reference-bearing parameter or receiver (or a value derived from it) into an indexed element or field of another parameter/receiver — or copies reference-bearing slice elements via
copy(dst, src)— the caller's destination and source bindings share mutable GC storage after the call returns. Previously,hy-checkonly recordedmay_shareedges for in-frame assignments (dst[0] = shared),copy(dst, src)directly in the caller frame, and return-value projections, leaving caller-side out-parameters and receiver containers unlinked from the stored argument.Root Cause & Soundness Coverage
loans.rs::record_callee_param_stores):self.fns) and user-defined struct methods (self.method_decls, unifying the receiver slot and parameter slots) up to bounded interprocedural depth (depth <= 4).dst[0] = v,dst["k"] = v,h.m = v,b.items[0] = v,dst[0] = h.m), local alias and container chains inside the helper (tmp := dst; val := v; tmp[0] = val, multi-value unpacks, branch/loop/match/select paths), built-incopy(dst, src)on reference-element slices inside the helper, and transitive helper-to-helper calls (outer_set(dst, v) -> inner_set(dst, v)).shape_may_shareso primitive value copies across helpers (dst["k"] = src["k"]onmap[string]intorcopy(dst, src)on[]int) do not introduce false-positivemay_shareedges.may_share&non_owned_origin/constpropagation:st.share_edge(dst_root, src_root)and propagatesnon_owned_originso:dstfreezessrcand vice versa (HYB-E3003, O5.2).dstafter storing a non-owned caller parameter/capturepinto it viaset(dst, p)is rejected withHYB-E3004(O5.1 / O5.4).constcomposite through an out-parameter container populated viaset(dst, const_m)is rejected withHYB-E3006(T22).closures.rs::check_stmt_boundaries&loans.rs::scan_block_const_writes):record_callee_param_storesinside closure bodies as well as the top-level Pass B walk so helper-frame out-parameter stores inside closures obey the same freeze and immutability rules.Verification
Added
compiler/crates/hy-check/tests/callee_store_share_issue_455.rs(7 integration tests covering slice/map/pointer-struct out-param stores, both move directions, user-defined struct methods, transitive helper chains, helpercopy(dst, src), closure-body calls,HYB-E3004non-owned parameter laundering,HYB-E3006constdeep immutability, and positive controls).cargo test --manifest-path compiler/Cargo.toml -p hy-check: all unit, integration, and corpus suites pass with 0 regressions.Submitted PR: fix(hy-check): track helper-frame out-param and receiver stores (#455) #493 (fix(hy-check): track helper-frame out-param and receiver stores (#455) #493)
Merge pr-493 (exantiv, fixes limitlessprojects#455): caller-side may_…
dezzy-music commentedon Oct 17, 2026
Hey maintainer! Senior systems & compiler engineer here. I've already resolved this helper-frame out-param store race condition in PR #470 with clean test suites passing 100% green. If you have any specific requirements, extra test cases, or adjustments you'd like made, I'm online right now and can turn them around in 20 minutes or less (maximum 1 hour). Ready to get this merged today!
Payout details: