Description
Here is how one does it:
- Create channels A and B
- Send a clone of A's SharedChan and send A's port to channel B
- Send a clone of B's SharedChan and send B's port to channel A
- Drop the original SharedChans
- Memory leak!
The Linux kernel has the exact same issue with file descriptor passing on Unix sockets and they solve it with an global in-kernel garbage collector for unix sockets (http://lxr.free-electrons.com/source/net/unix/garbage.c)
Rust can't do the GC approach easily because it can pass structures containing SharedChans in addition to just SharedChan like Linux.
However, we can prevent cycles just like we do for RWARC: by adding a Freeze bound to SharedChan's T and making sure SharedChan is no_freeze.
Should this be done?
If not, why shouldn't the Freeze be removed from RWARC too, since they are effectively equivalent functionality? (method calls on RWARC-protected objects are equivalent to sending a message via SharedChan to a task that calls the corresponding method)