diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index 06fe8a826cd..ec03a45594c 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -2600,6 +2600,7 @@ static inline void report_error(Thread* t, DWORD exception_code, //----------------------------------------------------------------------------- JNIEXPORT LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) { + PreserveLastError ple; if (InterceptOSException) return EXCEPTION_CONTINUE_SEARCH; PEXCEPTION_RECORD exception_record = exceptionInfo->ExceptionRecord; DWORD exception_code = exception_record->ExceptionCode; diff --git a/test/hotspot/gtest/utilities/test_vmerror.cpp b/test/hotspot/gtest/utilities/test_vmerror.cpp index a779133b711..ad2f2c3004f 100644 --- a/test/hotspot/gtest/utilities/test_vmerror.cpp +++ b/test/hotspot/gtest/utilities/test_vmerror.cpp @@ -28,6 +28,17 @@ #ifdef ASSERT +#ifdef _WINDOWS + +#include + +TEST_VM_ASSERT_MSG(vmErrorTest, fatalWithError, + "fatal error: GetLastError should be 6 - actually: 6") { + SetLastError(6); + fatal("GetLastError should be 6 - actually: %lu", GetLastError()); +} +#endif // WINDOWS + TEST_VM_ASSERT_MSG(vmErrorTest, resourceMark, "fatal error: memory leak: allocating without ResourceMark") {