Repository navigation
Description
Revision (git rev-parse HEAD)
c09e99202330948779033991e74d562df446a203 (origin/main)
The smallest .hy program that demonstrates it
Four closely related soundness gaps in compiler/crates/hy-check/src/closures.rs (check_stmt_boundaries, follow-up gaps to #137 and #141) and compiler/crates/hy-check/src/loans.rs (process_assign / process_local, follow-up gaps to #75 and #141) allow pure Tier-0 .hy programs (zero managed blocks) to pass hyb check with OK (0 diagnostics), compile cleanly with go build / go vet, and race under go run -race (WARNING: DATA RACE / fatal error: concurrent map writes):
Reproducer 1 — Type-ascribed local inside a closure (var alias map[string]int = m / let alias map[string]int = m) wipes pre-define alias and skips record_may_share / record_alias (follow-up gap in #137)
fn worker(m map[string]int, done chan<- bool) {
for i in 0..5000 {
m["k"] = i
}
done <- true
}
fn main() {
m := map[string]int{"k": 0}
done := make(chan bool, 2)
spawn_it := fn() {
var alias map[string]int = m
task worker(move alias, done)
}
spawn_it()
spawn_it()
<-done
<-done
}Reproducer 2 — Assignment rebind inside a closure (alias = m / m2 = m1) skips binding update, non_owned_origin inheritance, record_may_share, and record_alias (follow-up gap in #137)
fn worker(m map[string]int, done chan<- bool) {
for i in 0..5000 {
m["k"] = i
}
done <- true
}
fn main() {
m := map[string]int{"k": 0}
done := make(chan bool, 2)
spawn_it := fn() {
var alias map[string]int
alias = m
task worker(move alias, done)
}
spawn_it()
spawn_it()
<-done
<-done
}Reproducer 3 — Self-shadowing define inside a closure (m := m / m := same(m)) erases captured/parameter non_owned_origin (follow-up gap in #141)
fn worker(m map[string]int, done chan<- bool) {
for i in 0..5000 {
m["k"] = i
}
done <- true
}
fn main() {
m := map[string]int{"k": 0}
done := make(chan bool, 2)
spawn_it := fn() {
m := m
task worker(move m, done)
}
spawn_it()
spawn_it()
<-done
<-done
}Reproducer 4 — Self-rebind assignment (s = s[:], m = same(m)) and parameter-peer rebind (h2 := h; h = fresh; task worker(move h2, done)) erase non_owned_origin and sever may_share peers (follow-up gap in #75 & #141)
struct holder {
m map[string]int
}
fn same(m map[string]int) map[string]int {
return m
}
fn worker(m map[string]int, done chan<- bool) {
for i in 0..5000 {
m["k"] = i
}
done <- true
}
fn hworker(h holder, done chan<- bool) {
for i in 0..5000 {
h.m["k"] = i
}
done <- true
}
// (4a) Self-rebind of parameter (`m = same(m)` or `s = s[:]`) wipes `non_owned_origin`:
fn spawn_self_rebind(m map[string]int, done chan<- bool) {
m = same(m)
task worker(move m, done)
}
// (4b) Rebinding struct parameter `h` after `h2 := h` wipes `h`'s origin & share group
// before `move h2` runs:
fn spawn_peer_rebind(h holder, done chan<- bool) {
h2 := h
h = holder{m: map[string]int{"fresh": 0}}
task hworker(move h2, done)
}
// (4c) Self-rebind of owned `m1` (`m1 = same(m1)`) calls `st.share_clear("m1")` while
// `record_may_share` skips `root == name`, severing `m1` from `h := holder{m: m1}`:
fn main() {
m1 := map[string]int{"k": 0}
h := holder{m: m1}
m1 = same(m1)
done := make(chan bool, 1)
task worker(move m1, done)
for i in 0..5000 {
h.m["k"] = i
}
<-done
}Root Cause
closures.rs::check_stmt_boundaries—Stmt::Localwith type ascription (lines 132–150):
Lines 132–139 insertst.aliases.insert(l.names[0], resolved_root)beforedefine_binding, and lines 144–150 branch onif let Some(t) = &l.ty, callingck.define_binding(whose first line isst.aliases.remove(name); st.share_clear(name);) and skipping theelse if l.names.len() == l.values.len()block where [soundness] Local rebinds inside closures bypass alias tracking and non_owned_origin, allowing unsound task spawns #137 addedrecord_may_share,record_alias, andrecord_local_borrow_aliases. Any type-ascribed local inside a closure (var alias map[string]int = m) therefore loses both its alias link and itsnon_owned_origin.closures.rs::check_stmt_boundaries—Stmt::Assign(lines 345–349):
Stmt::Assigninside a closure only callsck.mark_move_in_value; it never updates target bindings (shape,ty,moved,non_owned_origin) and never invokesrecord_may_share,record_alias, orrecord_assign_borrow_aliases.closures.rs::check_stmt_boundaries— Self-shadowing define (m := m/m := same(m),lines 151–177):
PR fix(hy-check): self-shadowing define (m := m) keeps the shadowed binding's non-owned origin (HYB-E3004) #140 (fixing [soundness] Self-shadowing define (m := m) in an inner block drops the parameter/receiver non_owned_origin:move maccepted, data race #141) addedvalue_reads_storage_ofpre-shadowshadowed_origincapture toloans.rs::process_local, butclosures.rswas not updated. Inside a closure,m := moverwrites the captured/parameter binding withnon_owned_origin: Nonebeforerecord_alias/record_may_shareskipsrc == name.loans.rs::process_assign&process_local— Self-rebind and peer-rebind erasure (lines 861–910,1353–1397):- In
process_assign,non_ownedonly inspects bareExpr::Identandmove_operand_ident. When a binding is self-rebound (s = s[:],m = same(m),h = holder{m: h.m}),b.non_owned_originis overwritten withNone, andst.aliases.remove(name)+st.share_clear(name)sever all existing alias/may-share peers (h := holder{m: m1}) whilerecord_may_share/record_aliasskiproot == name. (Similarly, inprocess_local,m := same(m)callsdefine_binding->st.share_clear("m"), dropping priormay_sharepeers of outerm.) - When a non-owned struct/array parameter
his shallow-copied (h2 := h) andhis subsequently rebound (h = fresh),process_assignclearsh.non_owned_originandst.share_clear("h")without transferringh's non-owned origin onto its survivingmay_sharepeerh2.
- In
What the checker should say
- Reject Reproducers 1, 2, 3, 4a, and 4b with
HYB-E3004(tier0_rule: "A1b",O5.1/O5.4: cannot move non-owned binding or may-share peer). - Reject Reproducer 4c (and closure-local alias writes after
var m2 map[string]int = m1orm2 = m1) withHYB-E3003(tier0_rule: "A1b",O5.2: write through a live alias of a moved value).
What it actually said
All four reproducers pass hyb check on c09e992 with OK (0 diagnostics), compile cleanly under go build, and fail under go run -race with WARNING: DATA RACE / fatal error: concurrent map writes.
Claimed severity
P0 — data race reachable in the checked subset
Bounty Payout Wallet Addresses
- USDT (TRC20 / Tron):
TCQwxbpYVdRWYNDs1JbnKyVHNRVaRJg1io - USDT / USDC (ERC20 Ethereum / BEP20 BSC):
0x76d1c4283a2ff662ccf85c1f57655c29b4256756 - Self-Custody EVM Wallet (ETH / USDC / USDT / any EVM chain or token):
0x6Cf7Fc00857f2bbd12fBF2E11BC5AacEF0e97985 - USDC (Solana):
6dX8oqvvHj6Q936PVyTjVYKVk45soNpJ234aVqMm6ZJm
Activity
sparkysolutions10-pixel commentedon Oct 15, 2026
🤖 MiroFish Autonomous Bug Resolution & Proof of Fix
🛠️ Problem & Solution Overview
Issue Reference
Fixes #206
Description of Fix
This pull request provides a targeted resolution for the reported bug: "[soundness] Closure ascribed locals, closure assignments, and self/peer rebinds erase non_owned_origin and may_share (follow-up gaps in #75/#137/#141)".
🔬 Automated Reproduction & Regression Test Case
🧪 MiroFish Quality Assurance Verification
Signed-off-by)🤝 Contribution & Bounty Reward Note
I am contributing this patch as an independent software engineer / security researcher.
If this issue has an allocated cash bounty or your team sponsors open-source contributors, you can kindly transfer the bounty reward via my verified Razorpay Gateway:
🔗 Pay Bounty via Razorpay
(Supports UPI, Credit/Debit Cards, NetBanking, and International Cards with instant receipt).
(Corporate Accounting: Instant commercial invoice and W-8BEN tax documentation available upon request).
Thank you for maintaining this great project! 🙌
feat(bounty): live solution spec for limitlessprojects/Go-Hybrid#206 …
sonson0910 commentedon Oct 15, 2026
Note from issue author (
sonson0910): The companion fix and regression test suite for all 4 sub-gaps reported in this issue was submitted alongside this report in PR #207 (#207).fix(hy-check): preserve origin and may_share across closure ascribed/…
Merge pr-207 (sonson0910, fixes #206): closure ascribed/assign/self-r…
corpus: pin the limitlessprojects#399/limitlessprojects#301/limitless…