hotspot/src/os/posix/vm/os_posix.hpp
changeset 18943 7d0ef675e808
parent 13963 e5b53c306fb5
child 22826 3ee6886e718d
child 22234 da823d78ad65
--- a/hotspot/src/os/posix/vm/os_posix.hpp	Thu Jul 18 06:47:15 2013 -0400
+++ b/hotspot/src/os/posix/vm/os_posix.hpp	Wed Jul 17 13:48:15 2013 +0200
@@ -37,5 +37,24 @@
 
 };
 
+/*
+ * Crash protection for the watcher thread. Wrap the callback
+ * with a sigsetjmp and in case of a SIGSEGV/SIGBUS we siglongjmp
+ * back.
+ * To be able to use this - don't take locks, don't rely on destructors,
+ * don't make OS library calls, don't allocate memory, don't print,
+ * don't call code that could leave the heap / memory in an inconsistent state,
+ * or anything else where we are not in control if we suddenly jump out.
+ */
+class WatcherThreadCrashProtection : public StackObj {
+public:
+  WatcherThreadCrashProtection();
+  bool call(os::CrashProtectionCallback& cb);
+
+  static void check_crash_protection(int signal, Thread* thread);
+private:
+  void restore();
+  sigjmp_buf _jmpbuf;
+};
 
 #endif