90
91 // Prints a one-line description of a combination of sigaction.sa_flags.
92 static void print_sa_flags(outputStream* st, int flags);
93
94 static address ucontext_get_pc(const ucontext_t* ctx);
95 // Set PC into context. Needed for continuation after signal.
96 static void ucontext_set_pc(ucontext_t* ctx, address pc);
97
98 // Helper function; describes pthread attributes as short string. String is written
99 // to buf with len buflen; buf is returned.
100 static char* describe_pthread_attr(char* buf, size_t buflen, const pthread_attr_t* attr);
101
102 // A safe implementation of realpath which will not cause a buffer overflow if the resolved path
103 // is longer than PATH_MAX.
104 // On success, returns 'outbuf', which now contains the path.
105 // On error, it will return NULL and set errno. The content of 'outbuf' is undefined.
106 // On truncation error ('outbuf' too small), it will return NULL and set errno to ENAMETOOLONG.
107 static char* realpath(const char* filename, char* outbuf, size_t outbuflen);
108 };
109
110 /*
111 * Crash protection for the watcher thread. Wrap the callback
112 * with a sigsetjmp and in case of a SIGSEGV/SIGBUS we siglongjmp
113 * back.
114 * To be able to use this - don't take locks, don't rely on destructors,
115 * don't make OS library calls, don't allocate memory, don't print,
116 * don't call code that could leave the heap / memory in an inconsistent state,
117 * or anything else where we are not in control if we suddenly jump out.
118 */
119 class WatcherThreadCrashProtection : public StackObj {
120 public:
121 WatcherThreadCrashProtection();
122 bool call(os::CrashProtectionCallback& cb);
123
124 static void check_crash_protection(int signal, Thread* thread);
125 private:
126 void restore();
127 sigjmp_buf _jmpbuf;
128 };
129
|
90
91 // Prints a one-line description of a combination of sigaction.sa_flags.
92 static void print_sa_flags(outputStream* st, int flags);
93
94 static address ucontext_get_pc(const ucontext_t* ctx);
95 // Set PC into context. Needed for continuation after signal.
96 static void ucontext_set_pc(ucontext_t* ctx, address pc);
97
98 // Helper function; describes pthread attributes as short string. String is written
99 // to buf with len buflen; buf is returned.
100 static char* describe_pthread_attr(char* buf, size_t buflen, const pthread_attr_t* attr);
101
102 // A safe implementation of realpath which will not cause a buffer overflow if the resolved path
103 // is longer than PATH_MAX.
104 // On success, returns 'outbuf', which now contains the path.
105 // On error, it will return NULL and set errno. The content of 'outbuf' is undefined.
106 // On truncation error ('outbuf' too small), it will return NULL and set errno to ENAMETOOLONG.
107 static char* realpath(const char* filename, char* outbuf, size_t outbuflen);
108 };
109
110 // On POSIX platforms the signal handler is global so we just do the write.
111 static void write_memory_serialize_page_with_handler(JavaThread* thread) {
112 write_memory_serialize_page(thread);
113 }
114
115 /*
116 * Crash protection for the watcher thread. Wrap the callback
117 * with a sigsetjmp and in case of a SIGSEGV/SIGBUS we siglongjmp
118 * back.
119 * To be able to use this - don't take locks, don't rely on destructors,
120 * don't make OS library calls, don't allocate memory, don't print,
121 * don't call code that could leave the heap / memory in an inconsistent state,
122 * or anything else where we are not in control if we suddenly jump out.
123 */
124 class WatcherThreadCrashProtection : public StackObj {
125 public:
126 WatcherThreadCrashProtection();
127 bool call(os::CrashProtectionCallback& cb);
128
129 static void check_crash_protection(int signal, Thread* thread);
130 private:
131 void restore();
132 sigjmp_buf _jmpbuf;
133 };
134
|