From 3cb606ef5b21b5d65cb97b459f30cdeacd035669 Mon Sep 17 00:00:00 2001 From: David Holmes Date: Thu, 11 May 2023 00:51:15 +0000 Subject: [PATCH] 8306965: osThread allocation failures should not abort the VM Reviewed-by: lfoltan --- src/hotspot/os/aix/os_aix.cpp | 4 ++-- src/hotspot/os/bsd/os_bsd.cpp | 4 ++-- src/hotspot/os/linux/os_linux.cpp | 4 ++-- src/hotspot/os/windows/os_windows.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp index fe86adcc40a..160969df454 100644 --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -743,7 +743,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, assert(thread->osthread() == nullptr, "caller responsible"); // Allocate the OSThread object. - OSThread* osthread = new OSThread(); + OSThread* osthread = new (std::nothrow) OSThread(); if (osthread == nullptr) { return false; } @@ -857,7 +857,7 @@ bool os::create_attached_thread(JavaThread* thread) { #endif // Allocate the OSThread object - OSThread* osthread = new OSThread(); + OSThread* osthread = new (std::nothrow) OSThread(); if (osthread == nullptr) { return false; diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp index f4799e76a32..2079867bbb5 100644 --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -586,7 +586,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, assert(thread->osthread() == nullptr, "caller responsible"); // Allocate the OSThread object - OSThread* osthread = new OSThread(); + OSThread* osthread = new (std::nothrow) OSThread(); if (osthread == nullptr) { return false; } @@ -679,7 +679,7 @@ bool os::create_attached_thread(JavaThread* thread) { #endif // Allocate the OSThread object - OSThread* osthread = new OSThread(); + OSThread* osthread = new (std::nothrow) OSThread(); if (osthread == nullptr) { return false; diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index b6d2721343c..7bb99874848 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -851,7 +851,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, assert(thread->osthread() == nullptr, "caller responsible"); // Allocate the OSThread object - OSThread* osthread = new OSThread(); + OSThread* osthread = new (std::nothrow) OSThread(); if (osthread == nullptr) { return false; } @@ -975,7 +975,7 @@ bool os::create_attached_thread(JavaThread* thread) { #endif // Allocate the OSThread object - OSThread* osthread = new OSThread(); + OSThread* osthread = new (std::nothrow) OSThread(); if (osthread == nullptr) { return false; diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index 3a5dade91af..178630f86e9 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -568,7 +568,7 @@ unsigned __stdcall os::win32::thread_native_entry(void* t) { static OSThread* create_os_thread(Thread* thread, HANDLE thread_handle, int thread_id) { // Allocate the OSThread object - OSThread* osthread = new OSThread(); + OSThread* osthread = new (std::nothrow) OSThread(); if (osthread == nullptr) return nullptr; // Initialize the JDK library's interrupt event. @@ -673,7 +673,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, unsigned thread_id; // Allocate the OSThread object - OSThread* osthread = new OSThread(); + OSThread* osthread = new (std::nothrow) OSThread(); if (osthread == nullptr) { return false; }