www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23156] New: Thread should not rethrow Errors

https://issues.dlang.org/show_bug.cgi?id=23156

          Issue ID: 23156
           Summary: Thread should not rethrow Errors
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: schveiguy gmail.com

nothrow functions can skip critical cleanup code if Errors are thrown.

However, a thread aside from the main thread, which catches an Error, tries to
forward the error onto the main thread. It also attempts to run all thread
local static destructors.

This can cause problems if cleanup code that is skipped. For instance, a locked
resource may remain locked. If the main thread is waiting on that resource
before trying to join child threads, it may hang the entire process. If cleanup
code is skipped, the entire process may be in an invalid state, and other
threads should not be running.

The correct behavior should be for Errors to be caught in the thread start
code, printed, and then the entire process should exit, just like the main
thread does. If users want to handle the Error differently they should have to
use a separate out of band mechanism.

--
Jun 03 2022