-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Zero-initialize pthread struct only in debug builds. NFC #26857
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -279,14 +279,20 @@ void _emscripten_thread_free_data(pthread_t t) { | |
| emscripten_builtin_free(t->profilerBlock); | ||
| } | ||
| #endif | ||
| // Clear the self-reference to prevent inadvertent use and | ||
| // inform functions that validate it that the thread is no | ||
| // longer available. | ||
| t->self = NULL; | ||
|
|
||
| // Free all the entire thread block (called map_base because | ||
| // Free the entire thread block (called map_base because | ||
| // musl normally allocates this using mmap). This region | ||
| // includes the pthread structure itself. | ||
| unsigned char* block = t->map_base; | ||
| dbg("_emscripten_thread_free_data thread=%p map_base=%p", t, block); | ||
| #ifndef NDEBUG | ||
| // To aid in debugging, set the entire region to zero. | ||
| memset(block, 0, sizeof(struct pthread)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we actually use
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure, but I think that would break the |
||
| #endif | ||
| emscripten_builtin_free(block); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it not useful for debugging to reset this memory to something ? Maybe
0xfe? Maybe only in debug builds?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit e206e45 does this only for debug builds.