mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-24 05:14:52 +02:00
8187040: ThreadCritical crashes on Solaris if used between os::init and os::init_2
Reviewed-by: dholmes, stuefe
This commit is contained in:
parent
7a446900da
commit
04b79fa8f3
11 changed files with 8 additions and 54 deletions
|
@ -3443,8 +3443,6 @@ void os::init(void) {
|
||||||
|
|
||||||
init_random(1234567);
|
init_random(1234567);
|
||||||
|
|
||||||
ThreadCritical::initialize();
|
|
||||||
|
|
||||||
// Main_thread points to the aboriginal thread.
|
// Main_thread points to the aboriginal thread.
|
||||||
Aix::_main_thread = pthread_self();
|
Aix::_main_thread = pthread_self();
|
||||||
|
|
||||||
|
|
|
@ -38,12 +38,6 @@ static pthread_t tc_owner = 0;
|
||||||
static pthread_mutex_t tc_mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t tc_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static int tc_count = 0;
|
static int tc_count = 0;
|
||||||
|
|
||||||
void ThreadCritical::initialize() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThreadCritical::release() {
|
|
||||||
}
|
|
||||||
|
|
||||||
ThreadCritical::ThreadCritical() {
|
ThreadCritical::ThreadCritical() {
|
||||||
pthread_t self = pthread_self();
|
pthread_t self = pthread_self();
|
||||||
if (self != tc_owner) {
|
if (self != tc_owner) {
|
||||||
|
|
|
@ -3353,8 +3353,6 @@ void os::init(void) {
|
||||||
|
|
||||||
init_random(1234567);
|
init_random(1234567);
|
||||||
|
|
||||||
ThreadCritical::initialize();
|
|
||||||
|
|
||||||
Bsd::set_page_size(getpagesize());
|
Bsd::set_page_size(getpagesize());
|
||||||
if (Bsd::page_size() == -1) {
|
if (Bsd::page_size() == -1) {
|
||||||
fatal("os_bsd.cpp: os::init: sysconf failed (%s)", os::strerror(errno));
|
fatal("os_bsd.cpp: os::init: sysconf failed (%s)", os::strerror(errno));
|
||||||
|
|
|
@ -37,12 +37,6 @@ static pthread_t tc_owner = 0;
|
||||||
static pthread_mutex_t tc_mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t tc_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static int tc_count = 0;
|
static int tc_count = 0;
|
||||||
|
|
||||||
void ThreadCritical::initialize() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThreadCritical::release() {
|
|
||||||
}
|
|
||||||
|
|
||||||
ThreadCritical::ThreadCritical() {
|
ThreadCritical::ThreadCritical() {
|
||||||
pthread_t self = pthread_self();
|
pthread_t self = pthread_self();
|
||||||
if (self != tc_owner) {
|
if (self != tc_owner) {
|
||||||
|
|
|
@ -4768,8 +4768,6 @@ void os::init(void) {
|
||||||
|
|
||||||
init_random(1234567);
|
init_random(1234567);
|
||||||
|
|
||||||
ThreadCritical::initialize();
|
|
||||||
|
|
||||||
Linux::set_page_size(sysconf(_SC_PAGESIZE));
|
Linux::set_page_size(sysconf(_SC_PAGESIZE));
|
||||||
if (Linux::page_size() == -1) {
|
if (Linux::page_size() == -1) {
|
||||||
fatal("os_linux.cpp: os::init: sysconf failed (%s)",
|
fatal("os_linux.cpp: os::init: sysconf failed (%s)",
|
||||||
|
|
|
@ -37,12 +37,6 @@ static pthread_t tc_owner = 0;
|
||||||
static pthread_mutex_t tc_mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t tc_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static int tc_count = 0;
|
static int tc_count = 0;
|
||||||
|
|
||||||
void ThreadCritical::initialize() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThreadCritical::release() {
|
|
||||||
}
|
|
||||||
|
|
||||||
ThreadCritical::ThreadCritical() {
|
ThreadCritical::ThreadCritical() {
|
||||||
pthread_t self = pthread_self();
|
pthread_t self = pthread_self();
|
||||||
if (self != tc_owner) {
|
if (self != tc_owner) {
|
||||||
|
|
|
@ -4076,6 +4076,7 @@ int_fnP_cond_tP os::Solaris::_cond_broadcast;
|
||||||
int_fnP_cond_tP_i_vP os::Solaris::_cond_init;
|
int_fnP_cond_tP_i_vP os::Solaris::_cond_init;
|
||||||
int_fnP_cond_tP os::Solaris::_cond_destroy;
|
int_fnP_cond_tP os::Solaris::_cond_destroy;
|
||||||
int os::Solaris::_cond_scope = USYNC_THREAD;
|
int os::Solaris::_cond_scope = USYNC_THREAD;
|
||||||
|
bool os::Solaris::_synchronization_initialized;
|
||||||
|
|
||||||
void os::Solaris::synchronization_init() {
|
void os::Solaris::synchronization_init() {
|
||||||
if (UseLWPSynchronization) {
|
if (UseLWPSynchronization) {
|
||||||
|
@ -4125,6 +4126,7 @@ void os::Solaris::synchronization_init() {
|
||||||
os::Solaris::set_cond_destroy(::cond_destroy);
|
os::Solaris::set_cond_destroy(::cond_destroy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_synchronization_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool os::Solaris::liblgrp_init() {
|
bool os::Solaris::liblgrp_init() {
|
||||||
|
@ -4198,9 +4200,6 @@ void os::init(void) {
|
||||||
dladdr1_func = CAST_TO_FN_PTR(dladdr1_func_type, dlsym(hdl, "dladdr1"));
|
dladdr1_func = CAST_TO_FN_PTR(dladdr1_func_type, dlsym(hdl, "dladdr1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// (Solaris only) this switches to calls that actually do locking.
|
|
||||||
ThreadCritical::initialize();
|
|
||||||
|
|
||||||
main_thread = thr_self();
|
main_thread = thr_self();
|
||||||
|
|
||||||
// dynamic lookup of functions that may not be available in our lowest
|
// dynamic lookup of functions that may not be available in our lowest
|
||||||
|
|
|
@ -65,6 +65,8 @@ class Solaris {
|
||||||
static int_fnP_cond_tP _cond_destroy;
|
static int_fnP_cond_tP _cond_destroy;
|
||||||
static int _cond_scope;
|
static int _cond_scope;
|
||||||
|
|
||||||
|
static bool _synchronization_initialized;
|
||||||
|
|
||||||
typedef uintptr_t lgrp_cookie_t;
|
typedef uintptr_t lgrp_cookie_t;
|
||||||
typedef id_t lgrp_id_t;
|
typedef id_t lgrp_id_t;
|
||||||
typedef int lgrp_rsrc_t;
|
typedef int lgrp_rsrc_t;
|
||||||
|
@ -227,6 +229,8 @@ class Solaris {
|
||||||
static void set_cond_destroy(int_fnP_cond_tP func) { _cond_destroy = func; }
|
static void set_cond_destroy(int_fnP_cond_tP func) { _cond_destroy = func; }
|
||||||
static void set_cond_scope(int scope) { _cond_scope = scope; }
|
static void set_cond_scope(int scope) { _cond_scope = scope; }
|
||||||
|
|
||||||
|
static bool synchronization_initialized() { return _synchronization_initialized; }
|
||||||
|
|
||||||
static void set_lgrp_home(lgrp_home_func_t func) { _lgrp_home = func; }
|
static void set_lgrp_home(lgrp_home_func_t func) { _lgrp_home = func; }
|
||||||
static void set_lgrp_init(lgrp_init_func_t func) { _lgrp_init = func; }
|
static void set_lgrp_init(lgrp_init_func_t func) { _lgrp_init = func; }
|
||||||
static void set_lgrp_fini(lgrp_fini_func_t func) { _lgrp_fini = func; }
|
static void set_lgrp_fini(lgrp_fini_func_t func) { _lgrp_fini = func; }
|
||||||
|
|
|
@ -42,10 +42,9 @@
|
||||||
static mutex_t global_mut;
|
static mutex_t global_mut;
|
||||||
static thread_t global_mut_owner = -1;
|
static thread_t global_mut_owner = -1;
|
||||||
static int global_mut_count = 0;
|
static int global_mut_count = 0;
|
||||||
static bool initialized = false;
|
|
||||||
|
|
||||||
ThreadCritical::ThreadCritical() {
|
ThreadCritical::ThreadCritical() {
|
||||||
if (initialized) {
|
if (os::Solaris::synchronization_initialized()) {
|
||||||
thread_t owner = thr_self();
|
thread_t owner = thr_self();
|
||||||
if (global_mut_owner != owner) {
|
if (global_mut_owner != owner) {
|
||||||
if (os::Solaris::mutex_lock(&global_mut))
|
if (os::Solaris::mutex_lock(&global_mut))
|
||||||
|
@ -62,7 +61,7 @@ ThreadCritical::ThreadCritical() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadCritical::~ThreadCritical() {
|
ThreadCritical::~ThreadCritical() {
|
||||||
if (initialized) {
|
if (os::Solaris::synchronization_initialized()) {
|
||||||
assert(global_mut_owner == thr_self(), "must have correct owner");
|
assert(global_mut_owner == thr_self(), "must have correct owner");
|
||||||
assert(global_mut_count > 0, "must have correct count");
|
assert(global_mut_count > 0, "must have correct count");
|
||||||
--global_mut_count;
|
--global_mut_count;
|
||||||
|
@ -75,12 +74,3 @@ ThreadCritical::~ThreadCritical() {
|
||||||
assert (Threads::number_of_threads() == 0, "valid only during initialization");
|
assert (Threads::number_of_threads() == 0, "valid only during initialization");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadCritical::initialize() {
|
|
||||||
// This method is called at the end of os::init(). Until
|
|
||||||
// then, we don't do real locking.
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThreadCritical::release() {
|
|
||||||
}
|
|
||||||
|
|
|
@ -51,16 +51,6 @@ static DWORD lock_owner = -1;
|
||||||
// and found them ~30 times slower than the critical region code.
|
// and found them ~30 times slower than the critical region code.
|
||||||
//
|
//
|
||||||
|
|
||||||
void ThreadCritical::initialize() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void ThreadCritical::release() {
|
|
||||||
assert(lock_owner == -1, "Mutex being deleted while owned.");
|
|
||||||
assert(lock_count == -1, "Mutex being deleted while recursively locked");
|
|
||||||
assert(lock_event != NULL, "Sanity check");
|
|
||||||
CloseHandle(lock_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
ThreadCritical::ThreadCritical() {
|
ThreadCritical::ThreadCritical() {
|
||||||
DWORD current_thread = GetCurrentThreadId();
|
DWORD current_thread = GetCurrentThreadId();
|
||||||
|
|
||||||
|
|
|
@ -47,11 +47,6 @@
|
||||||
// or CHeapObj, due to initialization issues.
|
// or CHeapObj, due to initialization issues.
|
||||||
|
|
||||||
class ThreadCritical : public StackObj {
|
class ThreadCritical : public StackObj {
|
||||||
friend class os;
|
|
||||||
private:
|
|
||||||
static void initialize();
|
|
||||||
static void release();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ThreadCritical();
|
ThreadCritical();
|
||||||
~ThreadCritical();
|
~ThreadCritical();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue