From f5d3e1365e56ddf69cd7589bf83c3008e621f3bd Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Tue, 30 Mar 2021 17:15:07 +0000 Subject: [PATCH] Backport 554dd29fb67b9a25ad161920b57e238c06024938 --- src/hotspot/os/aix/os_aix.cpp | 48 ------------------------- src/hotspot/os/bsd/os_bsd.cpp | 50 -------------------------- src/hotspot/os/linux/os_linux.cpp | 56 +---------------------------- src/hotspot/os/posix/os_posix.cpp | 58 ++++++++++++++++++++++++++++++- 4 files changed, 58 insertions(+), 154 deletions(-) diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp index 15c7160fdcd..73826d07e0d 100644 --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -1064,54 +1064,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(); } diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp index c9aec705b9f..15f4b6ac5a8 100644 --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -929,56 +929,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; diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index f1bd6135b64..155007724d2 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ // no precompiled headers #include "jvm.h" -#include "classfile/classLoader.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/icBuffer.hpp" @@ -66,7 +65,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" @@ -1429,58 +1427,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() { diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp index a856ff0bd82..e5b67615d52 100644 --- a/src/hotspot/os/posix/os_posix.cpp +++ b/src/hotspot/os/posix/os_posix.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,19 +22,26 @@ * */ + #include "jvm.h" +#ifdef LINUX +#include "classfile/classLoader.hpp" +#endif #include "logging/log.hpp" #include "memory/allocation.inline.hpp" #include "os_posix.inline.hpp" +#include "runtime/arguments.hpp" #include "runtime/globals_extension.hpp" #include "utilities/globalDefinitions.hpp" #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" @@ -1812,3 +1819,52 @@ int os::PlatformMonitor::wait(jlong millis) { return OS_OK; } } + +//////////////////////////////////////////////////////////////////////////////// +// 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(); + } +}