Infinite hang when channel incompletely read
2c9bce3
Opened by Jeffrey Yasskin at
The following program hangs forever in trying to destroy the to_child chan, because it's waiting for the queue to be emptied by the child, which has completed and will never do so.
io fn incomplete_read(chan[chan[str]] for_incoming_chan) {
let port[str] incoming = port();
for_incoming_chan <| chan(incoming);
auto read_one <- incoming;
// Never read the second string.
}
io fn main() {
let port[chan[str]] get_to_child = port();
auto child = spawn incomplete_read(chan(get_to_child));
let chan[str] to_child <- get_to_child;
to_child <| "str 1";
to_child <| "never read";
}
Somewhat relevant: a similar race is commented about (and worked-around) in test/run-pass/obj-dtor.rs.
Roy Frostig at 2010-08-10 18:14:23
Fixed long ago. Now completes with:
rt: warning: '_unread == 0', at: rt/circular_buffer.cpp:29 freeing circular_buffer with 4 unread bytes
Graydon Hoare at 2011-01-27 01:54:13