I wrote some simple and naive code to check if a tree is isolated at runtime, 
see <https://github.com/zevv/nimsafesend>.

`isIsolated[]()` recursively traverses the passed (ref) objects and finds out 
if the passed ref is isolated, and thus safe to move to a different thread.

In main.nim I create a simple isolated tree of only 2 objects and send this 
over between two threads. This works fine for arc, but unfortunately orc does 
not agree with this and throws me a segfault. Valgrind tells me:
    
    
    ==126265== Invalid read of size 16
    ==126265==    at 0x10F3CB: unregisterCycle__system_2993 (orc.nim:147)
    ==126265==    by 0x10F3CB: rememberCycle__system_3352 (orc.nim:469)
    ==126265==    by 0x1134BB: nimDecRefIsLastCyclicStatic (orc.nim:497)
    ==126265==    by 0x1134BB: eqdestroy___main_219 (main.nim:16)
    ==126265==    by 0x1134BB: eqdestroy___main_206 (main.nim:16)
    ==126265==    by 0x1134BB: eqdestroy___main_206 (main.nim:16)
    ==126265==    by 0x1136E7: rxProc__main_23 (main.nim:16)
    ==126265==    by 0x111CE6: threadProcWrapDispatch__stdZthreads_105 
(threadimpl.nim:71)
    ==126265==    by 0x10A6C0: threadProcWrapper__stdZthreads_81 
(threadimpl.nim:106)
    ==126265==    by 0x4906849: start_thread (pthread_create.c:442)
    ==126265==    by 0x498952F: clone (clone.S:100)
    ==126265==  Address 0xfffffffffffffff0 is not stack'd, malloc'd or 
(recently) free'd
    
    
    
    Run

Reply via email to