diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp index 5a1d05c139c..0a092883fd4 100644 --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -769,7 +769,8 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, // Init thread attributes. pthread_attr_t attr; - pthread_attr_init(&attr); + int rslt = pthread_attr_init(&attr); + guarantee(rslt == 0, "pthread_attr_init has to return 0"); guarantee(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) == 0, "???"); // Make sure we run in 1:1 kernel-user-thread mode. @@ -803,6 +804,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, stack_size / K); thread->set_osthread(nullptr); delete osthread; + pthread_attr_destroy(&attr); return false; } diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index afaa5d9778b..40a576c09ae 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -911,7 +911,12 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, // init thread attributes pthread_attr_t attr; - pthread_attr_init(&attr); + int rslt = pthread_attr_init(&attr); + if (rslt != 0) { + thread->set_osthread(nullptr); + delete osthread; + return false; + } pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); // Calculate stack size if it's not specified by caller. @@ -960,6 +965,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, stack_size / K); thread->set_osthread(nullptr); delete osthread; + pthread_attr_destroy(&attr); return false; } diff --git a/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m b/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m index 33e850dbb38..66e0c362318 100644 --- a/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m +++ b/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m @@ -273,8 +273,10 @@ SplashCreateThread(Splash * splash) { pthread_attr_t attr; int rc; - pthread_attr_init(&attr); + int rslt = pthread_attr_init(&attr); + if (rslt != 0) return; rc = pthread_create(&thr, &attr, SplashScreenThread, (void *) splash); + pthread_attr_destroy(&attr); } void diff --git a/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c b/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c index e426ab69c94..c532f1658cb 100644 --- a/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c +++ b/src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c @@ -773,8 +773,10 @@ SplashCreateThread(Splash * splash) { pthread_attr_t attr; int rc; - pthread_attr_init(&attr); + int rslt = pthread_attr_init(&attr); + if (rslt != 0) return; rc = pthread_create(&thr, &attr, SplashScreenThread, (void *) splash); + pthread_attr_destroy(&attr); } void