Skip to content

fix(hy-check): track multi-return and try-unwrapped auto-addr loans (fixes #2052) - #2139

Open
jpereyra243-byte wants to merge 1 commit into
limitlessprojects:mainfrom
jpereyra243-byte:fix/collect-borrowed-roots-multi-return-try-2052
Open

jpereyra243-byte wants to merge 1 commit into
limitlessprojects:mainfrom
jpereyra243-byte:fix/collect-borrowed-roots-multi-return-try-2052

Conversation

@jpereyra243-byte

Copy link
Copy Markdown
Contributor

Summary

Fixes two provenance and borrow-classification soundness gaps in compiler/crates/hy-check/src/loans.rs that allowed multi-return calls and ?-unwrapped calls on auto-addressed *T receivers or *T parameters to bypass O5.2 (HYB-E3003 post-move alias freeze), O5.1 / O5.4 (HYB-E3004 non-owned parameter laundering), and T22 (HYB-E3006 deep const immutability) with 0 diagnostics, resulting in data races under go run -race:

  1. Checker::collect_borrowed_roots: Added call_any_result_may_share(st, callee) so multi-return functions and methods returning a non-sharing primitive in result 0 (e.g. (int, []int) or (int, holder)) correctly identify auto-addressed *T receivers and parameters as carrying borrowed GC storage.
  2. Checker::expr_has_borrow_shape: Unwrapped Expr::Try (?) before inspecting multi-return call results, ensuring fallible methods returning pointers (e.g. (int, *cell, error)) properly mark the auto-addressed receiver as borrowed.

Fixes #2052.

Changes

  • In compiler/crates/hy-check/src/loans.rs:
    • Added call_any_result_may_share inspecting all tuple return types of callee.
    • Unwrapped Expr::Try in expr_has_borrow_shape.
    • Called call_any_result_may_share in collect_borrowed_roots.
    • Added regression test multi_return_and_try_auto_addr_borrow_soundness covering O5.1/O5.4 (HYB-E3004), T22 (HYB-E3006), and O5.2 (HYB-E3003).

Settlement / Payout Wallet (Polygon / USDC): 0xC175c34c256598C7e1AD5B15503cFcED7Ed67e10

@github-actions github-actions Bot added the bot:stale-base Shepherd: behind main beyond threshold label Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:stale-base Shepherd: behind main beyond threshold

Projects

None yet

1 participant