This will prevent the main/1 orphaned threads, stack corrupted error when a thread spawned by a non-main thread outlives the main/1 function.
Now, if a detached thread spawns another thread, and that spawned thread executes longer that the main/1 thread and is not detached the VM will detect potential stack corruption and abort execution of the program.
This is undesirable since it is perfectly OK for a thread to outlive its parent thread if it is detached.
However, Viua currently lacks the notion of parent thread so if main/1 exits between the moment a thread is launched and the moment it is detached the VM will abort.
An easy fix is to make thread instruction explicitly set a parent on the thread being launched.
Then, if main/1 exits and there are undetached threads for which it is the parent thread - VM can be shot down; if there aren't any such threads - the execution can continue.
This will prevent the
main/1 orphaned threads, stack corrupted
error when a thread spawned by a non-main thread outlives themain/1
function.Now, if a detached thread spawns another thread, and that spawned thread executes longer that the
main/1
thread and is not detached the VM will detect potential stack corruption and abort execution of the program. This is undesirable since it is perfectly OK for a thread to outlive its parent thread if it is detached. However, Viua currently lacks the notion of parent thread so ifmain/1
exits between the moment a thread is launched and the moment it is detached the VM will abort. An easy fix is to makethread
instruction explicitly set a parent on the thread being launched. Then, ifmain/1
exits and there are undetached threads for which it is the parent thread - VM can be shot down; if there aren't any such threads - the execution can continue.