mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 09:34:38 +02:00
8218483: Crash in "assert(_daemon_threads_count->get_value() > daemon_count) failed: thread count mismatch 5 : 5"
Reviewed-by: dcubed, stuefe
This commit is contained in:
parent
18146afe7f
commit
2f20909d10
4 changed files with 16 additions and 15 deletions
|
@ -2021,6 +2021,10 @@ void JavaThread::exit(bool destroy_vm, ExitType exit_type) {
|
|||
_timer_exit_phase1.stop();
|
||||
_timer_exit_phase2.start();
|
||||
}
|
||||
|
||||
// Capture daemon status before the thread is marked as terminated.
|
||||
bool daemon = is_daemon(threadObj());
|
||||
|
||||
// Notify waiters on thread object. This has to be done after exit() is called
|
||||
// on the thread (if the thread is the last thread in a daemon ThreadGroup the
|
||||
// group should have the destroyed bit set before waiters are notified).
|
||||
|
@ -2089,7 +2093,7 @@ void JavaThread::exit(bool destroy_vm, ExitType exit_type) {
|
|||
_timer_exit_phase4.start();
|
||||
}
|
||||
// Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread
|
||||
Threads::remove(this);
|
||||
Threads::remove(this, daemon);
|
||||
|
||||
if (log_is_enabled(Debug, os, thread, timer)) {
|
||||
_timer_exit_phase4.stop();
|
||||
|
@ -2107,7 +2111,7 @@ void JavaThread::exit(bool destroy_vm, ExitType exit_type) {
|
|||
}
|
||||
}
|
||||
|
||||
void JavaThread::cleanup_failed_attach_current_thread() {
|
||||
void JavaThread::cleanup_failed_attach_current_thread(bool is_daemon) {
|
||||
if (active_handles() != NULL) {
|
||||
JNIHandleBlock* block = active_handles();
|
||||
set_active_handles(NULL);
|
||||
|
@ -2129,7 +2133,7 @@ void JavaThread::cleanup_failed_attach_current_thread() {
|
|||
|
||||
BarrierSet::barrier_set()->on_thread_detach(this);
|
||||
|
||||
Threads::remove(this);
|
||||
Threads::remove(this, is_daemon);
|
||||
this->smr_delete();
|
||||
}
|
||||
|
||||
|
@ -4455,7 +4459,7 @@ void Threads::add(JavaThread* p, bool force_daemon) {
|
|||
Events::log(p, "Thread added: " INTPTR_FORMAT, p2i(p));
|
||||
}
|
||||
|
||||
void Threads::remove(JavaThread* p) {
|
||||
void Threads::remove(JavaThread* p, bool is_daemon) {
|
||||
|
||||
// Reclaim the ObjectMonitors from the omInUseList and omFreeList of the moribund thread.
|
||||
ObjectSynchronizer::omFlush(p);
|
||||
|
@ -4484,11 +4488,8 @@ void Threads::remove(JavaThread* p) {
|
|||
}
|
||||
|
||||
_number_of_threads--;
|
||||
oop threadObj = p->threadObj();
|
||||
bool daemon = true;
|
||||
if (!is_daemon(threadObj)) {
|
||||
if (!is_daemon) {
|
||||
_number_of_non_daemon_threads--;
|
||||
daemon = false;
|
||||
|
||||
// Only one thread left, do a notify on the Threads_lock so a thread waiting
|
||||
// on destroy_vm will wake up.
|
||||
|
@ -4496,7 +4497,7 @@ void Threads::remove(JavaThread* p) {
|
|||
Threads_lock->notify_all();
|
||||
}
|
||||
}
|
||||
ThreadService::remove_thread(p, daemon);
|
||||
ThreadService::remove_thread(p, is_daemon);
|
||||
|
||||
// Make sure that safepoint code disregard this thread. This is needed since
|
||||
// the thread might mess around with locks after this point. This can cause it
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue