-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
(Unintended) Destruction of Thread object causes hard to debug crash #7172
Comments
@andreaferretti, please unmark |
I agree it is not a bug of threads - in some sense it is not a bug at all. Still I thought it would be useful to locate issues such as this when looking for thread-related problems |
Doesnt crash for me. Nim latest head. |
Crashes for me on Arch Linux with Clang and GCC |
@konqoro, please run executable many times , crashes can be not constant... |
Tried again and without '-d:release' crashes every single time. with release doesn't. gcc version 7.2.1 20180116 (GCC) manjaro |
Confirmed works on Windows, crashes on Ubuntu. |
I've run it several times (without |
I think that it is not clear from the docs what happens on createThread. |
Co-authored-by: Clay Sweetser <[email protected]>
…ang#20495) Co-authored-by: Clay Sweetser <[email protected]>
Me, and people trying to help me on the forum, spent a while to debug a crash, which was due to a Thread object being destroyed, while the thread is still running. In this particular case, I believe the Thread object was on the stack, but I assume the same would happen with a GCed Thread object.
Here is a simple example that causes the crash, at least for me on Windows, and was also reproducible on Archlinux:
If "var thread" is moved to the global scope, the crash does not happen.
It is not clear to me if the crash can be prevented though a compile-time error, but at least it would be good to have an error message that users understand. It might also be good to mention that this can happen in the Thread and/or createThread documentation.
The text was updated successfully, but these errors were encountered: