Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions src/hotspot/os/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2729,10 +2729,6 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
// Verify that OS save/restore AVX registers.
return Handle_Exception(exceptionInfo, VM_Version::cpuinfo_cont_addr());
}
#elif defined(_M_ARM64)
if (handle_safefetch(exception_code, pc, (void*)exceptionInfo->ContextRecord)) {
return EXCEPTION_CONTINUE_EXECUTION;
}
#endif

if (t != nullptr && t->is_Java_thread()) {
Expand Down Expand Up @@ -2765,8 +2761,10 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
// Fatal red zone violation.
overflow_state->disable_stack_red_zone();
tty->print_raw_cr("An unrecoverable stack overflow has occurred.");
#if !defined(USE_VECTORED_EXCEPTION_HANDLING)
report_error(t, exception_code, pc, exception_record,
exceptionInfo->ContextRecord);
#endif
return EXCEPTION_CONTINUE_SEARCH;
}
} else if (exception_code == EXCEPTION_ACCESS_VIOLATION) {
Expand Down Expand Up @@ -2822,8 +2820,10 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
#endif

// Stack overflow or null pointer exception in native code.
#if !defined(USE_VECTORED_EXCEPTION_HANDLING)
report_error(t, exception_code, pc, exception_record,
exceptionInfo->ContextRecord);
#endif
return EXCEPTION_CONTINUE_SEARCH;
} // /EXCEPTION_ACCESS_VIOLATION
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down Expand Up @@ -2897,21 +2897,41 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
}
}

bool should_report_error = (exception_code != EXCEPTION_BREAKPOINT);
#if !defined(USE_VECTORED_EXCEPTION_HANDLING)
if (exception_code != EXCEPTION_BREAKPOINT) {
report_error(t, exception_code, pc, exception_record,
exceptionInfo->ContextRecord);
}
#endif
return EXCEPTION_CONTINUE_SEARCH;
}

#if defined(USE_VECTORED_EXCEPTION_HANDLING)
LONG WINAPI topLevelVectoredExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
#if defined(_M_ARM64)
should_report_error = should_report_error &&
FAILED(exception_code) &&
(exception_code != EXCEPTION_UNCAUGHT_CXX_EXCEPTION);
address pc = (address) exceptionInfo->ContextRecord->Pc;
#elif defined(_M_AMD64)
address pc = (address) exceptionInfo->ContextRecord->Rip;
#else
address pc = (address) exceptionInfo->ContextRecord->Eip;
#endif

if (should_report_error) {
report_error(t, exception_code, pc, exception_record,
exceptionInfo->ContextRecord);
// Fast path for code part of the code cache
if (CodeCache::low_bound() <= pc && pc < CodeCache::high_bound()) {
return topLevelExceptionFilter(exceptionInfo);
}

// If the exception occurred in the codeCache, pass control
// to our normal exception handler.
CodeBlob* cb = CodeCache::find_blob(pc);
if (cb != nullptr) {
return topLevelExceptionFilter(exceptionInfo);
}

return EXCEPTION_CONTINUE_SEARCH;
}
#endif

#if defined(USE_VECTORED_EXCEPTION_HANDLING)
LONG WINAPI topLevelUnhandledExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
Expand Down Expand Up @@ -4637,7 +4657,7 @@ jint os::init_2(void) {
// Setup Windows Exceptions

#if defined(USE_VECTORED_EXCEPTION_HANDLING)
topLevelVectoredExceptionHandler = AddVectoredExceptionHandler(1, topLevelExceptionFilter);
topLevelVectoredExceptionHandler = AddVectoredExceptionHandler(1, topLevelVectoredExceptionFilter);
previousUnhandledExceptionFilter = SetUnhandledExceptionFilter(topLevelUnhandledExceptionFilter);
#endif

Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/os/windows/os_windows.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ class os::win32 {
// signal support
static void* install_signal_handler(int sig, signal_handler_t handler);
static void* user_handler();

static void context_set_pc(CONTEXT* uc, address pc);
};

#endif // OS_WINDOWS_OS_WINDOWS_HPP
65 changes: 0 additions & 65 deletions src/hotspot/os/windows/safefetch_static_windows.cpp

This file was deleted.

4 changes: 0 additions & 4 deletions src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ frame os::fetch_frame_from_context(const void* ucVoid) {
return frame(sp, fp, epc);
}

void os::win32::context_set_pc(CONTEXT* uc, address pc) {
uc->Pc = (intptr_t)pc;
}

bool os::win32::get_frame_at_stack_banging_point(JavaThread* thread,
struct _EXCEPTION_POINTERS* exceptionInfo, address pc, frame* fr) {
PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
Expand Down
65 changes: 0 additions & 65 deletions src/hotspot/os_cpu/windows_aarch64/safefetch_windows_aarch64.S

This file was deleted.

2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/safefetch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// Safefetch allows to load a value from a location that's not known
// to be valid. If the load causes a fault, the error value is returned.

#if defined(_WIN32) && !defined(_M_ARM64)
#ifdef _WIN32
// Windows uses Structured Exception Handling
#include "safefetch_windows.hpp"
#elif defined(ZERO) || defined (_AIX)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void testNativeExceptionReporting() throws Exception {
assertTrue(Files.exists(hsErrPath));

Pattern[] positivePatterns = {
Pattern.compile(".*Internal Error \\(0xdeadbeef\\).*")
Pattern.compile(".*Internal Error \\(0x2a\\).*")
};
HsErrFileUtils.checkHsErrFileContent(hsErrFile, positivePatterns, null, true /* check end marker */, false /* verbose */);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@

#include <Windows.h>

// Use an exception code that causes the FAILED() macro to return true.
const DWORD EX_CODE = 0xdeadbeef;
const DWORD EX_CODE = 42;

JNIEXPORT void JNICALL Java_UncaughtNativeExceptionTest_00024Crasher_throwException(JNIEnv* env, jclass cls) {
RaiseException(EX_CODE, EXCEPTION_NONCONTINUABLE, 0, NULL);
Expand Down
Loading