Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8263564: Consolidate POSIX code for runtime exit support: os::shutdow…
…n, os::abort and os::die

Reviewed-by: mikael
  • Loading branch information
David Holmes committed Mar 15, 2021
1 parent da9ead5 commit 554dd29fb67b9a25ad161920b57e238c06024938
Showing with 55 additions and 152 deletions.
  1. +0 −48 src/hotspot/os/aix/os_aix.cpp
  2. +0 −50 src/hotspot/os/bsd/os_bsd.cpp
  3. +0 −54 src/hotspot/os/linux/os_linux.cpp
  4. +55 −0 src/hotspot/os/posix/os_posix.cpp
@@ -1046,54 +1046,6 @@ struct tm* os::localtime_pd(const time_t* clock, struct tm* res) {
return localtime_r(clock, res);
}

////////////////////////////////////////////////////////////////////////////////
// runtime exit support

// Note: os::shutdown() might be called very early during initialization, or
// called from signal handler. Before adding something to os::shutdown(), make
// sure it is async-safe and can handle partially initialized VM.
void os::shutdown() {

// allow PerfMemory to attempt cleanup of any persistent resources
perfMemory_exit();

// needs to remove object in file system
AttachListener::abort();

// flush buffered output, finish log files
ostream_abort();

// Check for abort hook
abort_hook_t abort_hook = Arguments::abort_hook();
if (abort_hook != NULL) {
abort_hook();
}
}

// Note: os::abort() might be called very early during initialization, or
// called from signal handler. Before adding something to os::abort(), make
// sure it is async-safe and can handle partially initialized VM.
void os::abort(bool dump_core, void* siginfo, const void* context) {
os::shutdown();
if (dump_core) {
::abort(); // dump core
}

::exit(1);
}

// Die immediately, no exit hook, no abort hook, no cleanup.
// Dump a core file, if possible, for debugging.
void os::die() {
if (TestUnresponsiveErrorHandler && !CreateCoredumpOnCrash) {
// For TimeoutInErrorHandlingTest.java, we just kill the VM
// and don't take the time to generate a core file.
os::signal_raise(SIGKILL);
} else {
::abort();
}
}

intx os::current_thread_id() {
return (intx)pthread_self();
}
@@ -867,56 +867,6 @@ struct tm* os::localtime_pd(const time_t* clock, struct tm* res) {
return localtime_r(clock, res);
}

////////////////////////////////////////////////////////////////////////////////
// runtime exit support

// Note: os::shutdown() might be called very early during initialization, or
// called from signal handler. Before adding something to os::shutdown(), make
// sure it is async-safe and can handle partially initialized VM.
void os::shutdown() {

// allow PerfMemory to attempt cleanup of any persistent resources
perfMemory_exit();

// needs to remove object in file system
AttachListener::abort();

// flush buffered output, finish log files
ostream_abort();

// Check for abort hook
abort_hook_t abort_hook = Arguments::abort_hook();
if (abort_hook != NULL) {
abort_hook();
}

}

// Note: os::abort() might be called very early during initialization, or
// called from signal handler. Before adding something to os::abort(), make
// sure it is async-safe and can handle partially initialized VM.
void os::abort(bool dump_core, void* siginfo, const void* context) {
os::shutdown();
if (dump_core) {
::abort(); // dump core
}

::exit(1);
}

// Die immediately, no exit hook, no abort hook, no cleanup.
// Dump a core file, if possible, for debugging.
void os::die() {
if (TestUnresponsiveErrorHandler && !CreateCoredumpOnCrash) {
// For TimeoutInErrorHandlingTest.java, we just kill the VM
// and don't take the time to generate a core file.
os::signal_raise(SIGKILL);
} else {
// _exit() on BsdThreads only kills current thread
::abort();
}
}

// Information of current thread in variety of formats
pid_t os::Bsd::gettid() {
int retval = -1;
@@ -24,7 +24,6 @@

// no precompiled headers
#include "jvm.h"
#include "classfile/classLoader.hpp"
#include "classfile/vmSymbols.hpp"
#include "code/icBuffer.hpp"
#include "code/vtableStubs.hpp"
@@ -65,7 +64,6 @@
#include "runtime/vm_version.hpp"
#include "signals_posix.hpp"
#include "semaphore_posix.hpp"
#include "services/attachListener.hpp"
#include "services/memTracker.hpp"
#include "services/runtimeService.hpp"
#include "utilities/align.hpp"
@@ -1356,58 +1354,6 @@ struct tm* os::localtime_pd(const time_t* clock, struct tm* res) {
return localtime_r(clock, res);
}

////////////////////////////////////////////////////////////////////////////////
// runtime exit support

// Note: os::shutdown() might be called very early during initialization, or
// called from signal handler. Before adding something to os::shutdown(), make
// sure it is async-safe and can handle partially initialized VM.
void os::shutdown() {

// allow PerfMemory to attempt cleanup of any persistent resources
perfMemory_exit();

// needs to remove object in file system
AttachListener::abort();

// flush buffered output, finish log files
ostream_abort();

// Check for abort hook
abort_hook_t abort_hook = Arguments::abort_hook();
if (abort_hook != NULL) {
abort_hook();
}

}

// Note: os::abort() might be called very early during initialization, or
// called from signal handler. Before adding something to os::abort(), make
// sure it is async-safe and can handle partially initialized VM.
void os::abort(bool dump_core, void* siginfo, const void* context) {
os::shutdown();
if (dump_core) {
if (DumpPrivateMappingsInCore) {
ClassLoader::close_jrt_image();
}
::abort(); // dump core
}

::exit(1);
}

// Die immediately, no exit hook, no abort hook, no cleanup.
// Dump a core file, if possible, for debugging.
void os::die() {
if (TestUnresponsiveErrorHandler && !CreateCoredumpOnCrash) {
// For TimeoutInErrorHandlingTest.java, we just kill the VM
// and don't take the time to generate a core file.
os::signal_raise(SIGKILL);
} else {
::abort();
}
}

// thread_id is kernel thread id (similar to Solaris LWP id)
intx os::current_thread_id() { return os::Linux::gettid(); }
int os::current_process_id() {
@@ -22,7 +22,11 @@
*
*/


#include "jvm.h"
#ifdef LINUX
#include "classfile/classLoader.hpp"
#endif
#include "jvmtifiles/jvmti.h"
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
@@ -33,10 +37,12 @@
#include "runtime/frame.inline.hpp"
#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/sharedRuntime.hpp"
#include "services/attachListener.hpp"
#include "services/memTracker.hpp"
#include "runtime/atomic.hpp"
#include "runtime/java.hpp"
#include "runtime/orderAccess.hpp"
#include "runtime/perfMemory.hpp"
#include "utilities/align.hpp"
#include "utilities/events.hpp"
#include "utilities/formatBuffer.hpp"
@@ -1843,3 +1849,52 @@ int os::fork_and_exec(const char* cmd, bool prefer_vfork) {
}
}
}

////////////////////////////////////////////////////////////////////////////////
// runtime exit support

// Note: os::shutdown() might be called very early during initialization, or
// called from signal handler. Before adding something to os::shutdown(), make
// sure it is async-safe and can handle partially initialized VM.
void os::shutdown() {

// allow PerfMemory to attempt cleanup of any persistent resources
perfMemory_exit();

// needs to remove object in file system
AttachListener::abort();

// flush buffered output, finish log files
ostream_abort();

// Check for abort hook
abort_hook_t abort_hook = Arguments::abort_hook();
if (abort_hook != NULL) {
abort_hook();
}

}

// Note: os::abort() might be called very early during initialization, or
// called from signal handler. Before adding something to os::abort(), make
// sure it is async-safe and can handle partially initialized VM.
void os::abort(bool dump_core, void* siginfo, const void* context) {
os::shutdown();
if (dump_core) {
LINUX_ONLY(if (DumpPrivateMappingsInCore) ClassLoader::close_jrt_image();)
::abort(); // dump core
}
::exit(1);
}

// Die immediately, no exit hook, no abort hook, no cleanup.
// Dump a core file, if possible, for debugging.
void os::die() {
if (TestUnresponsiveErrorHandler && !CreateCoredumpOnCrash) {
// For TimeoutInErrorHandlingTest.java, we just kill the VM
// and don't take the time to generate a core file.
os::signal_raise(SIGKILL);
} else {
::abort();
}
}

0 comments on commit 554dd29

Please sign in to comment.