Issue 23156 - Thread should not rethrow Errors
Summary: Thread should not rethrow Errors
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords: safe
Depends on:
Blocks:
 
Reported: 2022-06-04 02:05 UTC by Steven Schveighoffer
Modified: 2024-12-07 13:42 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Steven Schveighoffer 2022-06-04 02:05:30 UTC
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.
Comment 1 dlangBugzillaToGithub 2024-12-07 13:42:05 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/17448

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB