55 * found in the LICENSE file.
66 */
77
8- #define _GNU_SOURCE
98#include "pthread_impl.h"
109#include "stdio_impl.h"
1110#include "assert.h"
@@ -108,7 +107,7 @@ int __pthread_create(pthread_t* restrict res,
108107 void * (* entry )(void * ),
109108 void * restrict arg ) {
110109 // Note on LSAN: lsan intercepts/wraps calls to pthread_create so any
111- // allocation we do here should be considered leaks.
110+ // allocations we do here should not be considered leaks.
112111 // See: lsan_interceptors.cpp.
113112 if (!res ) {
114113 return EINVAL ;
@@ -292,10 +291,10 @@ void _emscripten_thread_free_data(pthread_t t) {
292291}
293292
294293void _emscripten_thread_exit (void * result ) {
295- struct pthread * self = __pthread_self ();
294+ pthread_t self = __pthread_self ();
296295 assert (self );
297296
298- self -> canceldisable = PTHREAD_CANCEL_DISABLE ;
297+ self -> canceldisable = 1 ;
299298 self -> cancelasync = 0 ;
300299 self -> result = result ;
301300
@@ -344,8 +343,8 @@ void _emscripten_thread_exit(void* result) {
344343 // Not hosting a pthread anymore in this worker set __pthread_self to NULL
345344 __set_thread_state (NULL , 0 , 0 , 1 );
346345
347- /* This atomic potentially competes with a concurrent pthread_detach
348- * call; the loser is responsible for freeing thread resources. */
346+ // This atomic potentially competes with a concurrent pthread_detach
347+ // call; the loser is responsible for freeing thread resources.
349348 int state = a_cas (& self -> detach_state , DT_JOINABLE , DT_EXITING );
350349
351350 if (state == DT_DETACHED ) {
@@ -363,7 +362,7 @@ void _emscripten_thread_exit(void* result) {
363362 }
364363}
365364
366- // Mark as `no_sanitize("address"` since emscripten_pthread_exit destroys
365+ // Mark as `no_sanitize("address") ` since emscripten_pthread_exit destroys
367366// the current thread and runs its exit handlers. Without this asan injects
368367// a call to __asan_handle_no_return before emscripten_unwind_to_js_event_loop
369368// which seem to cause a crash later down the line.
0 commit comments