This runs fine when executed in the main thread...
puts"Run test in the main thread"run_test()
...but fails when a Fiber or Thread is involved:
puts"Run test in a fiber"beginFiber.newdorun_test()end.resumerescueSystemStackErrorputs"Fiber died."endputs"Run test in a thread"beginThread.abort_on_exception=trueThread.newdorun_test(600)# 600 is not chosen arbitrary: this is the first number where it fails here.endsleep(3)rescueSystemStackErrorputs"Thread died."end
Note that the recursion depth between Fiber and Thread differs.
The example script above produces the following output with my machine:
Run test in the main thread
Run test in a fiber
Run test in a thread
This should be resolvable by replacing the recursion in each, detached_subtree_copy and elsewhere with the respective iterative representation. each could possibly be fixed like this:
We are using rubytree to display different kinds of taxonomies. The graphs are built using user input and sometimes users create very long branches (probably by accident). We will eventually filter those branches, but for that we have to find them first. Note that the example above is quite artificial; if the node names are longer, it should crash with a smaller depth. We had one case where it crashed for a tree of depth 40.