diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-10-11 08:54:33 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-10-11 11:55:36 +0300 |
commit | 268bf0195358a3009fe7c091ff7e907c9df8d06b (patch) | |
tree | 7f603247d1e051d46e36187392b97b22d081e3e1 /win32_threads.c | |
parent | 20a94399951f3f0aa27ce885c3ca2163dba47803 (diff) | |
download | bdwgc-268bf0195358a3009fe7c091ff7e907c9df8d06b.tar.gz |
Fix missing result check of pthread_attr_getdetachstate in pthread_create
* pthread_support.c (pthread_create): Call ABORT() if
pthread_attr_getdetachstate() has failed.
* win32_threads.c [GC_PTHREADS] (GC_pthread_create): Likewise.
* win32_threads.c [GC_PTHREADS] (start_info.detached): Change type from
GC_bool to int (to match the type of the 2nd argument of
pthread_attr_getdetachstate).
Diffstat (limited to 'win32_threads.c')
-rw-r--r-- | win32_threads.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/win32_threads.c b/win32_threads.c index a45bddc8..b794c765 100644 --- a/win32_threads.c +++ b/win32_threads.c @@ -2743,7 +2743,7 @@ GC_INNER void GC_thr_init(void) struct start_info { void *(*start_routine)(void *); void *arg; - GC_bool detached; + int detached; }; GC_API int GC_pthread_join(pthread_t thread, void **retval) @@ -2819,12 +2819,9 @@ GC_INNER void GC_thr_init(void) si -> arg = arg; GC_dirty(si); REACHABLE_AFTER_DIRTY(arg); - if (attr != 0 && - pthread_attr_getdetachstate(attr, &si->detached) - == PTHREAD_CREATE_DETACHED) { - si->detached = TRUE; - } - + if (attr != NULL + && pthread_attr_getdetachstate(attr, &(si -> detached)) != 0) + ABORT("pthread_attr_getdetachstate failed"); # ifdef DEBUG_THREADS GC_log_printf("About to create a thread from %p(0x%lx)\n", (void *)GC_PTHREAD_PTRVAL(pthread_self()), |