Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread should not rethrow Errors #17448

Open
dlangBugzillaToGithub opened this issue Jun 4, 2022 · 0 comments
Open

Thread should not rethrow Errors #17448

dlangBugzillaToGithub opened this issue Jun 4, 2022 · 0 comments
Labels

Comments

@dlangBugzillaToGithub
Copy link

Steven Schveighoffer (@schveiguy) reported this on 2022-06-04T02:05:30Z

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

Description

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.
@thewilsonator thewilsonator added the Druntime Specific to druntime label Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants