mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8015884: runThese crashed with SIGSEGV, hs_err has an error instead of stacktrace
Dl_info struct should only be used if dladdr() has returned non-zero (no errors) and always check the dladdr() return value; Dl_info.dli_sname and Dl_info.dli_saddr fields should only be used if non-NULL; update/improve runtime/6888954/vmerrors.sh test Reviewed-by: dsamersoff, zgu, hseigel, coleenp
This commit is contained in:
parent
5de65fba93
commit
765f5cd4e7
11 changed files with 351 additions and 232 deletions
|
@ -314,8 +314,8 @@ bool is_error_reported() {
|
|||
#ifndef PRODUCT
|
||||
#include <signal.h>
|
||||
|
||||
void test_error_handler(size_t test_num)
|
||||
{
|
||||
void test_error_handler() {
|
||||
uintx test_num = ErrorHandlerTest;
|
||||
if (test_num == 0) return;
|
||||
|
||||
// If asserts are disabled, use the corresponding guarantee instead.
|
||||
|
@ -327,6 +327,8 @@ void test_error_handler(size_t test_num)
|
|||
|
||||
const char* const eol = os::line_separator();
|
||||
const char* const msg = "this message should be truncated during formatting";
|
||||
char * const dataPtr = NULL; // bad data pointer
|
||||
const void (*funcPtr)(void) = (const void(*)()) 0xF; // bad function pointer
|
||||
|
||||
// Keep this in sync with test/runtime/6888954/vmerrors.sh.
|
||||
switch (n) {
|
||||
|
@ -348,11 +350,16 @@ void test_error_handler(size_t test_num)
|
|||
case 9: ShouldNotCallThis();
|
||||
case 10: ShouldNotReachHere();
|
||||
case 11: Unimplemented();
|
||||
// This is last because it does not generate an hs_err* file on Windows.
|
||||
case 12: os::signal_raise(SIGSEGV);
|
||||
// There's no guarantee the bad data pointer will crash us
|
||||
// so "break" out to the ShouldNotReachHere().
|
||||
case 12: *dataPtr = '\0'; break;
|
||||
// There's no guarantee the bad function pointer will crash us
|
||||
// so "break" out to the ShouldNotReachHere().
|
||||
case 13: (*funcPtr)(); break;
|
||||
|
||||
default: ShouldNotReachHere();
|
||||
default: tty->print_cr("ERROR: %d: unexpected test_num value.", n);
|
||||
}
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
#endif // !PRODUCT
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue