Skip to content

[soundness] hy-check(channel_liveness): function parameter capabilities (hy.send_cap[T] / hy.recv_cap[T]) untracked, bypassing linearity, affine transfer, and terminal lifecycle checks (#4200 regression) #4416

Description

@seenorht

The smallest .hy program that demonstrates it

Tested on commit \�1627e8\ (\upstream/main, Session 187-cont2) with \hyb check repro.hy:

\\hy
// repro1_unclosed_sender.hy — send capability parameter leaked without closing
fn worker(tx hy.send_cap[int]) {
tx.send(42)
// tx is never closed or moved; receiver deadlocks waiting for EOF
}

fn main() {
tx, rx := hy.pipeint
task worker(move tx)
rx.drain()
}
\\

Companion soundness escapes sharing the same root cause in \compiler/crates/hy-check/src/channel_liveness.rs:

\\hy
// repro2_double_move.hy — parameter capability moved more than once into tasks
fn sub(tx hy.send_cap[int]) {
tx.close()
}

fn forwarder(tx hy.send_cap[int]) {
task sub(move tx)
task sub(move tx) // duplicates linear send capability across concurrent tasks!
}

fn main() {
tx, rx := hy.pipeint
task forwarder(move tx)
rx.drain()
}
\\

\\hy
// repro3_use_after_move.hy — affine parameter capability used after move
fn sub(tx hy.send_cap[int]) {
tx.close()
}

fn forwarder(tx hy.send_cap[int]) {
task sub(move tx)
tx.send(10) // use-after-move accepted without HYB-E3001!
}

fn main() {
tx, rx := hy.pipeint
task forwarder(move tx)
rx.drain()
}
\\

\\hy
// repro4_undrained_recv.hy — receive capability parameter leaked without draining
fn receiver(rx hy.recv_cap[int]) {
v := rx.recv()
_ = v
// rx is never drained or moved before function returns; messages abandoned!
}

fn main() {
tx, rx := hy.pipeint
tx.close()
task receiver(move rx)
}
\\

\\hy
// repro5_unmoved_task_capture.hy — parameter capability captured without move
fn sub(tx hy.send_cap[int]) {
tx.close()
}

fn forwarder(tx hy.send_cap[int]) {
task sub(tx) // unmoved capture across task boundary accepted without HYB-E3002!
tx.close()
}

fn main() {
tx, rx := hy.pipeint
task forwarder(move tx)
rx.drain()
}
\\

What the checker should say

  • **
    epro1_unclosed_sender.hy**: Reject (\exit 1) with *\HYB-E4004* (\linear send capability 'tx' was not closed before scope exit).
  • **
    epro2_double_move.hy**: Reject (\exit 1) with *\HYB-E3001* (\�ffine capability 'tx' moved more than once).
  • **
    epro3_use_after_move.hy**: Reject (\exit 1) with *\HYB-E3001* (\use of moved linear capability 'tx').
  • **
    epro4_undrained_recv.hy**: Reject (\exit 1) with *\HYB-E4005* (\linear receive capability 'rx' was not drained before scope exit).
  • **
    epro5_unmoved_task_capture.hy**: Reject (\exit 1) with *\HYB-E3002* (\unmoved capture 'tx' across task boundary is forbidden; must be explicitly transferred with 'move').

What it actually said

\\ ext
$ hyb check repro1_unclosed_sender.hy
repro1_unclosed_sender.hy: OK (0 diagnostics)
\\

(All five repros exit \

Activity

  1. added a commit that references this issue on Nov 19, 2026
    e152ccf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions