@@ -2628,14 +2628,13 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
26282628 DWORD exception_code = exception_record->ExceptionCode ;
26292629#if defined(_M_ARM64)
26302630 address pc = (address) exceptionInfo->ContextRecord ->Pc ;
2631+
2632+ if (handle_safefetch (exception_code, pc, (void *)exceptionInfo->ContextRecord )) {
2633+ return EXCEPTION_CONTINUE_EXECUTION ;
2634+ }
26312635#elif defined(_M_AMD64)
26322636 address pc = (address) exceptionInfo->ContextRecord ->Rip ;
2633- #else
2634- #error unknown architecture
2635- #endif
2636- Thread* t = Thread::current_or_null_safe ();
26372637
2638- #if defined(_M_AMD64)
26392638 if ((exception_code == EXCEPTION_ACCESS_VIOLATION ) &&
26402639 VM_Version::is_cpuinfo_segv_addr (pc)) {
26412640 // Verify that OS save/restore AVX registers.
@@ -2648,6 +2647,8 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
26482647 VM_Version::clear_apx_test_state ();
26492648 return Handle_Exception (exceptionInfo, VM_Version::cpuinfo_cont_addr_apx ());
26502649 }
2650+ #else
2651+ #error unknown architecture
26512652#endif
26522653
26532654#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
@@ -2658,6 +2659,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
26582659 }
26592660#endif
26602661
2662+ Thread* t = Thread::current_or_null_safe ();
26612663 if (t != nullptr && t->is_Java_thread ()) {
26622664 JavaThread* thread = JavaThread::cast (t);
26632665 bool in_java = thread->thread_state () == _thread_in_Java;
@@ -2688,10 +2690,8 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
26882690 // Fatal red zone violation.
26892691 overflow_state->disable_stack_red_zone ();
26902692 tty->print_raw_cr (" An unrecoverable stack overflow has occurred." );
2691- #if !defined(USE_VECTORED_EXCEPTION_HANDLING)
26922693 report_error (t, exception_code, pc, exception_record,
26932694 exceptionInfo->ContextRecord );
2694- #endif
26952695 return EXCEPTION_CONTINUE_SEARCH ;
26962696 }
26972697 } else if (exception_code == EXCEPTION_ACCESS_VIOLATION ) {
@@ -2743,10 +2743,8 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
27432743 }
27442744
27452745 // Stack overflow or null pointer exception in native code.
2746- #if !defined(USE_VECTORED_EXCEPTION_HANDLING)
27472746 report_error (t, exception_code, pc, exception_record,
27482747 exceptionInfo->ContextRecord );
2749- #endif
27502748 return EXCEPTION_CONTINUE_SEARCH ;
27512749 } // /EXCEPTION_ACCESS_VIOLATION
27522750 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -2821,41 +2819,21 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
28212819 }
28222820 }
28232821
2824- #if !defined(USE_VECTORED_EXCEPTION_HANDLING)
2825- if (exception_code != EXCEPTION_BREAKPOINT ) {
2826- report_error (t, exception_code, pc, exception_record,
2827- exceptionInfo->ContextRecord );
2828- }
2829- #endif
2830- return EXCEPTION_CONTINUE_SEARCH ;
2831- }
2822+ bool should_report_error = (exception_code != EXCEPTION_BREAKPOINT );
28322823
2833- #if defined(USE_VECTORED_EXCEPTION_HANDLING)
2834- LONG WINAPI topLevelVectoredExceptionFilter (struct _EXCEPTION_POINTERS * exceptionInfo) {
2835- PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord ;
28362824#if defined(_M_ARM64)
2837- address pc = (address) exceptionInfo->ContextRecord ->Pc ;
2838- #elif defined(_M_AMD64)
2839- address pc = (address) exceptionInfo->ContextRecord ->Rip ;
2840- #else
2841- #error unknown architecture
2825+ should_report_error = should_report_error &&
2826+ FAILED (exception_code) &&
2827+ (exception_code != EXCEPTION_UNCAUGHT_CXX_EXCEPTION );
28422828#endif
28432829
2844- // Fast path for code part of the code cache
2845- if (CodeCache::low_bound () <= pc && pc < CodeCache::high_bound ()) {
2846- return topLevelExceptionFilter (exceptionInfo);
2847- }
2848-
2849- // If the exception occurred in the codeCache, pass control
2850- // to our normal exception handler.
2851- CodeBlob* cb = CodeCache::find_blob (pc);
2852- if (cb != nullptr ) {
2853- return topLevelExceptionFilter (exceptionInfo);
2830+ if (should_report_error) {
2831+ report_error (t, exception_code, pc, exception_record,
2832+ exceptionInfo->ContextRecord );
28542833 }
28552834
28562835 return EXCEPTION_CONTINUE_SEARCH ;
28572836}
2858- #endif
28592837
28602838#if defined(USE_VECTORED_EXCEPTION_HANDLING)
28612839LONG WINAPI topLevelUnhandledExceptionFilter (struct _EXCEPTION_POINTERS * exceptionInfo) {
@@ -4488,7 +4466,7 @@ jint os::init_2(void) {
44884466 // Setup Windows Exceptions
44894467
44904468#if defined(USE_VECTORED_EXCEPTION_HANDLING)
4491- topLevelVectoredExceptionHandler = AddVectoredExceptionHandler (1 , topLevelVectoredExceptionFilter );
4469+ topLevelVectoredExceptionHandler = AddVectoredExceptionHandler (1 , topLevelExceptionFilter );
44924470 previousUnhandledExceptionFilter = SetUnhandledExceptionFilter (topLevelUnhandledExceptionFilter);
44934471#endif
44944472
0 commit comments