--- a/src/hotspot/os/bsd/os_bsd.cpp Fri Oct 26 08:23:52 2018 -0400
+++ b/src/hotspot/os/bsd/os_bsd.cpp Fri Oct 19 09:39:29 2018 +0200
@@ -644,6 +644,9 @@
// Thread start routine for all newly created threads
static void *thread_native_entry(Thread *thread) {
+
+ thread->record_stack_base_and_size();
+
// Try to randomize the cache line index of hot stack frames.
// This helps when threads of the same stack traces evict each other's
// cache lines. The threads can be either from the same JVM instance, or
@@ -696,20 +699,15 @@
}
// call one more level start routine
- thread->run();
+ thread->call_run();
+
+ // Note: at this point the thread object may already have deleted itself.
+ // Prevent dereferencing it from here on out.
+ thread = NULL;
log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ", pthread id: " UINTX_FORMAT ").",
os::current_thread_id(), (uintx) pthread_self());
- // If a thread has not deleted itself ("delete this") as part of its
- // termination sequence, we have to ensure thread-local-storage is
- // cleared before we actually terminate. No threads should ever be
- // deleted asynchronously with respect to their termination.
- if (Thread::current_or_null_safe() != NULL) {
- assert(Thread::current_or_null_safe() == thread, "current thread is wrong");
- thread->clear_thread_current();
- }
-
return 0;
}