Repository navigation
fix(hy-check): edge call results to may-share arguments on define (#73) - #74
Closed
milkingndb-oss wants to merge 1 commit into
Closed
milkingndb-oss wants to merge 1 commit into
milkingndb-oss wants to merge 1 commit into
Conversation
…mitlessprojects#73) A define whose value is a call only recorded sharing when the RESULT shape was a reference alias (limitlessprojects#38's record_alias Call arm), so two forms created an untracked peer that the later `move` did not freeze: * a shallow struct copy through a call — `h2 := alias_holder(h1)` (result shape Struct: not a binding alias, and record_may_share had no Call arm at all), and * a generic identity — `m2 := id(m)` with `fn id[t any](x t) t` (the result type resolves through the type parameter to Unknown, so even a MAP argument bypassed both recorders). Both passed `hyb check` with 0 diagnostics while the emitted Go raced (`fatal error: concurrent map writes` — `go worker(agg)` and the sender writing `alias` hit the same map store). record_may_share now has a Call arm: when the result may share GC storage (or is unresolvable — O4.9 fail-closed, same argument corpus 26 pinned for the alias path), edge the new binding to every may-share argument root and to the method receiver. A concrete scalar/string result stays a copy-out (no edge), so `x := wrap(m)` + `move m` keeps accepting. * corpus 28 pins the generic send-form (REJECT A1b); VERDICTS.md row + distribution appended, parse count 27 -> 28 * hy-check/tests/call_share.rs pins the struct form, the generic spawn-form, the scalar copy-out control, and the limitlessprojects#35 direct-copy regression * cargo test --workspace: 294 passed; corpus harness: 28/28 verdict agreement; all 10 examples still check OK Fixes limitlessprojects#73
This was referenced Oct 14, 2026
Owner
|
Landed on |
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.
Fixes #73
What
record_may_sharehad noExpr::Callarm, andrecord_alias's Call arm only fires when the result shape is a reference alias (Map/Slice/Pointer). A call that hands back storage reachable from an argument therefore created an untracked peer: the latermovefroze only the original binding, and a write through the peer was accepted while the emitted Go raced.Two repro families, one root cause (both reported and reproduced on
main@ 8fb9238 withhyb check?OK (0 diagnostics)andgo run?fatal error: concurrent map writes):h2 := alias_holder(h1)wherefn alias_holder(h holder) holder { return h }- result shape isStruct, whichis_reference_alias()excludes, andrecord_may_shareskipped calls entirely. The direct formh2 := h1was already correctly rejected ([soundness] Shallow struct/array copy and non-bare-ident aliases bypass O5.2 move freeze (h2 := h1,m2 := (agg),s2 := s1[:],holder{m: agg}) #27/checker: freeze all may-share aliases on move (fix #27) #35) - only the call spelling slipped through.m2 := id(m)withfn id[t any](x t) t- the result type resolves through the type parameter toUnknown, so even a map argument bypassed [soundness] Alias returned through a function call (alias := same(m)) is not frozen bymove m, accepted with 0 diagnostics and races #38's alias recorder (the non-genericfn id(m map[string]int) map[string]inttwin is correctly rejected today). Slice variant behaves the same.The fix
Give
record_may_shareaCallarm with the same no-interprocedural-summary argument corpus 26 pinned for the alias path: when the result may share GC storage or is unresolvable (O4.9 fail-closed), edge the new binding to every non-movemay-share argument root and to the method receiver (x := r.method(...)).Precision: a concrete scalar/string result is a copy-out (no edge) -
x := wrap(m)+move mstill accepts, pinned by a control test. Reference-shaped results now record both the alias (#38, unchanged) and the share edge - the same twin recordingm2 := mgets for the lexical form.Verification
cargo test --workspacecall_sharetests)tools/corpus_harness.pyhyb checkon all 10examples/OK (0 diagnostics)(incl.07-lru-generics- no generic false-rejects)HYB-E3003"write through a live alias of a moved value"Test plan (for the reviewer)
cargo test -p hy-check --test call_share- struct form, generic spawn-form, scalar copy-out control, checker: freeze all may-share aliases on move (fix #27) #35 direct-copy regression.python tools/corpus_harness.py --bin <target>/release/hyb- 28/28 including the new28-generic-call-return-alias-freeze.hy(REJECT A1b, appended to VERDICTS.md per the amendment rule).hyb checkrejects all three; before this commit they pass with 0 diagnostics and the emitted Go fatals.Notes / out of scope
check_non_owned_movederivesnon_owned_originfrom the alias chain only, so moving a share peer of a parameter (h2 := h; task f(move h2)inside a fn with paramh) passes even for the direct-copy form - that is an O5.1 gap that exists onmaintoday independent of calls (repro:param-struct.hy, stillOK (0 diagnostics)after this fix). Separate issue to follow so this PR stays reviewable.hy-check, but this changesrecord_may_share/record_alias-adjacent define-path logic only - no closure pass, alias scoping, or move shape classification touched.Before/after checker output (issue #73 repro 1)