-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix race condition in
pthread_create
handle initialization (#15043)
The thread routine may be started before `GC.pthread_create` returns; `Thread#start` then calls `Crystal::System::Thread#stack_address`, which may call `LibC.pthread_getattr_np` before `GC.pthread_create` initializes the `@system_handle` instance variable, hence the segmentation fault. (On musl-libc, [the underlying non-atomic store occurs right before `LibC.pthread_create` returns](https://git.musl-libc.org/cgit/musl/tree/src/thread/pthread_create.c?id=dd1e63c3638d5f9afb857fccf6ce1415ca5f1b8b#n389).) Thus there needs to be some kind of synchronization.
- Loading branch information
1 parent
8692740
commit 2821fbb
Showing
4 changed files
with
19 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters