From 0d147af1c4ecfe24c46952e059a78ad1e6b28553 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 21 Oct 2014 00:54:28 +0400 Subject: Fix missing error handling of pthread_attr_init/getstacksize * misc.c (GC_init): Explicitly ignore returned value of pthread_mutexattr_destroy. * os_dep.c (GC_get_main_stack_base, GC_get_stack_base, GC_dirty_init): Likewise. * pthread_support.c (start_mark_threads, pthread_create): Likewise. * tests/test.c (main): Likewise. * win32_threads.c (start_mark_threads): Likewise. * pthread_support.c (pthread_create): ABORT (with the appropriate message) in case of pthread_attr_getstacksize or pthread_attr_init failure. * tests/test.c (main): Print error code and FAIL if pthread_attr_init or pthread_attr_setstacksize failed (only if GC_PTHREADS). --- os_dep.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'os_dep.c') diff --git a/os_dep.c b/os_dep.c index 4a77d31e..1709c8e4 100644 --- a/os_dep.c +++ b/os_dep.c @@ -1201,13 +1201,13 @@ GC_INNER word GC_page_size = 0; if (pthread_getattr_np(pthread_self(), &attr) == 0) { if (pthread_attr_getstack(&attr, &stackaddr, &size) == 0 && stackaddr != NULL) { - pthread_attr_destroy(&attr); + (void)pthread_attr_destroy(&attr); # ifdef STACK_GROWS_DOWN stackaddr = (char *)stackaddr + size; # endif return (ptr_t)stackaddr; } - pthread_attr_destroy(&attr); + (void)pthread_attr_destroy(&attr); } WARN("pthread_getattr_np or pthread_attr_getstack failed" " for main thread\n", 0); @@ -1284,7 +1284,7 @@ GC_INNER word GC_page_size = 0; if (pthread_attr_getstack(&attr, &(b -> mem_base), &size) != 0) { ABORT("pthread_attr_getstack failed"); } - pthread_attr_destroy(&attr); + (void)pthread_attr_destroy(&attr); # ifdef STACK_GROWS_DOWN b -> mem_base = (char *)(b -> mem_base) + size; # endif @@ -4186,7 +4186,7 @@ GC_INNER void GC_dirty_init(void) /* This will call the real pthread function, not our wrapper */ if (pthread_create(&thread, &attr, GC_mprotect_thread, NULL) != 0) ABORT("pthread_create failed"); - pthread_attr_destroy(&attr); + (void)pthread_attr_destroy(&attr); /* Setup the sigbus handler for ignoring the meaningless SIGBUSs */ # ifdef BROKEN_EXCEPTION_HANDLING -- cgit v1.2.1