Wed, 17 Jul 2013 13:48:15 +0200
8020701: Avoid crashes in WatcherThread
Reviewed-by: acorn, dcubed, dsimms
nloodin@3783 | 1 | /* |
mikael@4153 | 2 | * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
nloodin@3783 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
nloodin@3783 | 4 | * |
nloodin@3783 | 5 | * This code is free software; you can redistribute it and/or modify it |
nloodin@3783 | 6 | * under the terms of the GNU General Public License version 2 only, as |
nloodin@3783 | 7 | * published by the Free Software Foundation. |
nloodin@3783 | 8 | * |
nloodin@3783 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
nloodin@3783 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
nloodin@3783 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
nloodin@3783 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
nloodin@3783 | 13 | * accompanied this code). |
nloodin@3783 | 14 | * |
nloodin@3783 | 15 | * You should have received a copy of the GNU General Public License version |
nloodin@3783 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
nloodin@3783 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
nloodin@3783 | 18 | * |
nloodin@3783 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
nloodin@3783 | 20 | * or visit www.oracle.com if you need additional information or have any |
nloodin@3783 | 21 | * questions. |
nloodin@3783 | 22 | * |
nloodin@3783 | 23 | */ |
nloodin@3783 | 24 | |
nloodin@3783 | 25 | #ifndef OS_POSIX_VM_OS_POSIX_HPP |
nloodin@3783 | 26 | #define OS_POSIX_VM_OS_POSIX_HPP |
nloodin@3783 | 27 | class Posix { |
nloodin@3783 | 28 | friend class os; |
nloodin@3783 | 29 | |
nloodin@3783 | 30 | protected: |
nloodin@3783 | 31 | static void print_distro_info(outputStream* st); |
nloodin@3783 | 32 | static void print_rlimit_info(outputStream* st); |
nloodin@3783 | 33 | static void print_uname_info(outputStream* st); |
nloodin@3783 | 34 | static void print_libversion_info(outputStream* st); |
nloodin@3783 | 35 | static void print_load_average(outputStream* st); |
nloodin@3783 | 36 | |
nloodin@3783 | 37 | |
nloodin@3783 | 38 | }; |
nloodin@3783 | 39 | |
rbackman@5424 | 40 | /* |
rbackman@5424 | 41 | * Crash protection for the watcher thread. Wrap the callback |
rbackman@5424 | 42 | * with a sigsetjmp and in case of a SIGSEGV/SIGBUS we siglongjmp |
rbackman@5424 | 43 | * back. |
rbackman@5424 | 44 | * To be able to use this - don't take locks, don't rely on destructors, |
rbackman@5424 | 45 | * don't make OS library calls, don't allocate memory, don't print, |
rbackman@5424 | 46 | * don't call code that could leave the heap / memory in an inconsistent state, |
rbackman@5424 | 47 | * or anything else where we are not in control if we suddenly jump out. |
rbackman@5424 | 48 | */ |
rbackman@5424 | 49 | class WatcherThreadCrashProtection : public StackObj { |
rbackman@5424 | 50 | public: |
rbackman@5424 | 51 | WatcherThreadCrashProtection(); |
rbackman@5424 | 52 | bool call(os::CrashProtectionCallback& cb); |
rbackman@5424 | 53 | |
rbackman@5424 | 54 | static void check_crash_protection(int signal, Thread* thread); |
rbackman@5424 | 55 | private: |
rbackman@5424 | 56 | void restore(); |
rbackman@5424 | 57 | sigjmp_buf _jmpbuf; |
rbackman@5424 | 58 | }; |
nloodin@3783 | 59 | |
nloodin@3783 | 60 | #endif |