File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -279,14 +279,20 @@ void _emscripten_thread_free_data(pthread_t t) {
279279 emscripten_builtin_free (t -> profilerBlock );
280280 }
281281#endif
282+ // Clear the self-reference to prevent inadvertent use and
283+ // inform functions that validate it that the thread is no
284+ // longer available.
285+ t -> self = NULL ;
282286
283- // Free all the entire thread block (called map_base because
287+ // Free the entire thread block (called map_base because
284288 // musl normally allocates this using mmap). This region
285289 // includes the pthread structure itself.
286290 unsigned char * block = t -> map_base ;
287291 dbg ("_emscripten_thread_free_data thread=%p map_base=%p" , t , block );
292+ #ifndef NDEBUG
288293 // To aid in debugging, set the entire region to zero.
289294 memset (block , 0 , sizeof (struct pthread ));
295+ #endif
290296 emscripten_builtin_free (block );
291297}
292298
You can’t perform that action at this time.
0 commit comments