Skip to content

Commit cfeb7d6

Browse files
committed
8350497: os::create_thread unify init thread attributes part across UNIX platforms
Reviewed-by: dholmes
1 parent 8cfebc4 commit cfeb7d6

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/hotspot/os/aix/os_aix.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,12 @@ bool os::create_thread(Thread* thread, ThreadType thr_type,
711711
// Init thread attributes.
712712
pthread_attr_t attr;
713713
int rslt = pthread_attr_init(&attr);
714-
guarantee(rslt == 0, "pthread_attr_init has to return 0");
715-
guarantee(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) == 0, "???");
714+
if (rslt != 0) {
715+
thread->set_osthread(nullptr);
716+
delete osthread;
717+
return false;
718+
}
719+
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
716720

717721
// Make sure we run in 1:1 kernel-user-thread mode.
718722
guarantee(pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM) == 0, "???");

src/hotspot/os/bsd/os_bsd.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,12 @@ bool os::create_thread(Thread* thread, ThreadType thr_type,
637637

638638
// init thread attributes
639639
pthread_attr_t attr;
640-
pthread_attr_init(&attr);
640+
int rslt = pthread_attr_init(&attr);
641+
if (rslt != 0) {
642+
thread->set_osthread(nullptr);
643+
delete osthread;
644+
return false;
645+
}
641646
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
642647

643648
// calculate stack size if it's not specified by caller

0 commit comments

Comments
 (0)