annotate src/share/vm/utilities/vmError.hpp @ 12199:38f750491293

8022335: Native stack walk while generating hs_err does not work on Windows x64 Summary: Use WinDbg API StackWalk64() Reviewed-by: zgu, dholmes
author iklam
date Fri, 06 Sep 2013 08:42:42 -0700
parents 068b406e307f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
11060
068b406e307f 7060111: race condition in VMError::report_and_die()
fparain
parents: 10161
diff changeset
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1490
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1490
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1490
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
25 #ifndef SHARE_VM_UTILITIES_VMERROR_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
26 #define SHARE_VM_UTILITIES_VMERROR_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
28 #include "utilities/globalDefinitions.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
29
4917
db006a85bf91 7141259: Native stack is missing in hs_err
zgu
parents: 2204
diff changeset
30 class Decoder;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class VM_ReportJavaOutOfMemory;
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 class VMError : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 friend class VM_ReportJavaOutOfMemory;
4917
db006a85bf91 7141259: Native stack is missing in hs_err
zgu
parents: 2204
diff changeset
35 friend class Decoder;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 int _id; // Solaris/Linux signals: 0 - SIGRTMAX
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // Windows exceptions: 0xCxxxxxxx system errors
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // 0x8xxxxxxx system warnings
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 const char * _message;
1490
f03d0a26bf83 6888954: argument formatting for assert() and friends
jcoomes
parents: 1384
diff changeset
42 const char * _detail_msg;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 Thread * _thread; // NULL if it's native thread
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // additional info for crashes
a61af66fc99e Initial load
duke
parents:
diff changeset
48 address _pc; // faulting PC
a61af66fc99e Initial load
duke
parents:
diff changeset
49 void * _siginfo; // ExceptionRecord on Windows,
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // siginfo_t on Solaris/Linux
a61af66fc99e Initial load
duke
parents:
diff changeset
51 void * _context; // ContextRecord on Windows,
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // ucontext_t on Solaris/Linux
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // additional info for VM internal errors
a61af66fc99e Initial load
duke
parents:
diff changeset
55 const char * _filename;
603
dbbe28fc66b5 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 513
diff changeset
56 int _lineno;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // used by fatal error handler
a61af66fc99e Initial load
duke
parents:
diff changeset
59 int _current_step;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 const char * _current_step_info;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 int _verbose;
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
62 // First error, and its thread id. We must be able to handle native thread,
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
63 // so use thread id instead of Thread* to identify thread.
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
64 static VMError* volatile first_error;
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
65 static volatile jlong first_error_tid;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
66
2204
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 2095
diff changeset
67 // Core dump status, false if we have been unable to write a core/minidump for some reason
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 2095
diff changeset
68 static bool coredump_status;
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 2095
diff changeset
69
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 2095
diff changeset
70 // When coredump_status is set to true this will contain the name/path to the core/minidump,
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 2095
diff changeset
71 // if coredump_status if false, this will (hopefully) contain a useful error explaining why
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 2095
diff changeset
72 // no core/minidump has been written to disk
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 2095
diff changeset
73 static char coredump_message[O_BUFLEN];
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 2095
diff changeset
74
0
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // used by reporting about OOM
a61af66fc99e Initial load
duke
parents:
diff changeset
76 size_t _size;
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // set signal handlers on Solaris/Linux or the default exception filter
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // on Windows, to handle recursive crashes.
a61af66fc99e Initial load
duke
parents:
diff changeset
80 void reset_signal_handlers();
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // handle -XX:+ShowMessageBoxOnError. buf is used to format the message string
a61af66fc99e Initial load
duke
parents:
diff changeset
83 void show_message_box(char* buf, int buflen);
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // generate an error report
a61af66fc99e Initial load
duke
parents:
diff changeset
86 void report(outputStream* st);
a61af66fc99e Initial load
duke
parents:
diff changeset
87
1384
c544d979f886 6944503: Improved Zero crash dump
twisti
parents: 628
diff changeset
88 // generate a stack trace
c544d979f886 6944503: Improved Zero crash dump
twisti
parents: 628
diff changeset
89 static void print_stack_trace(outputStream* st, JavaThread* jt,
c544d979f886 6944503: Improved Zero crash dump
twisti
parents: 628
diff changeset
90 char* buf, int buflen, bool verbose = false);
c544d979f886 6944503: Improved Zero crash dump
twisti
parents: 628
diff changeset
91
0
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // accessor
1490
f03d0a26bf83 6888954: argument formatting for assert() and friends
jcoomes
parents: 1384
diff changeset
93 const char* message() const { return _message; }
f03d0a26bf83 6888954: argument formatting for assert() and friends
jcoomes
parents: 1384
diff changeset
94 const char* detail_msg() const { return _detail_msg; }
10161
746b070f5022 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 6842
diff changeset
95 bool should_report_bug(unsigned int id) {
746b070f5022 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 6842
diff changeset
96 return (id != OOM_MALLOC_ERROR) && (id != OOM_MMAP_ERROR);
746b070f5022 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 6842
diff changeset
97 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
98
11060
068b406e307f 7060111: race condition in VMError::report_and_die()
fparain
parents: 10161
diff changeset
99 static fdStream out;
068b406e307f 7060111: race condition in VMError::report_and_die()
fparain
parents: 10161
diff changeset
100 static fdStream log; // error log used by VMError::report_and_die()
068b406e307f 7060111: race condition in VMError::report_and_die()
fparain
parents: 10161
diff changeset
101
0
a61af66fc99e Initial load
duke
parents:
diff changeset
102 public:
10161
746b070f5022 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 6842
diff changeset
103
0
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // Constructor for crashes
2095
36c186bcc085 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 1972
diff changeset
105 VMError(Thread* thread, unsigned int sig, address pc, void* siginfo,
36c186bcc085 6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents: 1972
diff changeset
106 void* context);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // Constructor for VM internal errors
1490
f03d0a26bf83 6888954: argument formatting for assert() and friends
jcoomes
parents: 1384
diff changeset
108 VMError(Thread* thread, const char* filename, int lineno,
f03d0a26bf83 6888954: argument formatting for assert() and friends
jcoomes
parents: 1384
diff changeset
109 const char* message, const char * detail_msg);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
110
1490
f03d0a26bf83 6888954: argument formatting for assert() and friends
jcoomes
parents: 1384
diff changeset
111 // Constructor for VM OOM errors
f03d0a26bf83 6888954: argument formatting for assert() and friends
jcoomes
parents: 1384
diff changeset
112 VMError(Thread* thread, const char* filename, int lineno, size_t size,
10161
746b070f5022 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 6842
diff changeset
113 VMErrorType vm_err_type, const char* message);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // Constructor for non-fatal errors
a61af66fc99e Initial load
duke
parents:
diff changeset
115 VMError(const char* message);
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // return a string to describe the error
a61af66fc99e Initial load
duke
parents:
diff changeset
118 char *error_string(char* buf, int buflen);
a61af66fc99e Initial load
duke
parents:
diff changeset
119
2204
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 2095
diff changeset
120 // Report status of core/minidump
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 2095
diff changeset
121 static void report_coredump_status(const char* message, bool status);
63d374c54045 7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents: 2095
diff changeset
122
0
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // main error reporting function
a61af66fc99e Initial load
duke
parents:
diff changeset
124 void report_and_die();
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // reporting OutOfMemoryError
a61af66fc99e Initial load
duke
parents:
diff changeset
127 void report_java_out_of_memory();
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // returns original flags for signal, if it was resetted, or -1 if
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // signal was not changed by error reporter
a61af66fc99e Initial load
duke
parents:
diff changeset
131 static int get_resetted_sigflags(int sig);
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // returns original handler for signal, if it was resetted, or NULL if
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // signal was not changed by error reporter
a61af66fc99e Initial load
duke
parents:
diff changeset
135 static address get_resetted_sighandler(int sig);
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
136
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
137 // check to see if fatal error reporting is in progress
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
138 static bool fatal_error_in_progress() { return first_error != NULL; }
12199
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11060
diff changeset
139
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11060
diff changeset
140 static jlong get_first_error_tid() {
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11060
diff changeset
141 return first_error_tid;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11060
diff changeset
142 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
143 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
144
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
145 #endif // SHARE_VM_UTILITIES_VMERROR_HPP