Skip to content

Commit 568dc29

Browse files
committed
8185734: [Windows] Structured Exception Catcher missing around gtest execution
Reviewed-by: dholmes, ihse
1 parent 3ab1dfe commit 568dc29

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

make/RunTests.gmk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ define SetupRunGtestTestBody
608608
$$(FIXPATH) $$(TEST_IMAGE_DIR)/hotspot/gtest/$$($1_VARIANT)/gtestLauncher \
609609
-jdk $(JDK_UNDER_TEST) $$($1_GTEST_FILTER) \
610610
--gtest_output=xml:$$($1_TEST_RESULTS_DIR)/gtest.xml \
611+
--gtest_catch_exceptions=0 \
611612
$$($1_GTEST_REPEAT) $$(GTEST_OPTIONS) $$(GTEST_VM_OPTIONS) \
612613
$$(GTEST_JAVA_OPTIONS) $$($1_AOT_OPTIONS) \
613614
> >($(TEE) $$($1_TEST_RESULTS_DIR)/gtest.txt) \

src/hotspot/os/windows/os_windows.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ struct tm* os::gmtime_pd(const time_t* clock, struct tm* res) {
512512
return NULL;
513513
}
514514

515+
JNIEXPORT
515516
LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo);
516517

517518
// Thread start routine for all newly created threads
@@ -2441,6 +2442,7 @@ static inline void report_error(Thread* t, DWORD exception_code,
24412442
}
24422443

24432444
//-----------------------------------------------------------------------------
2445+
JNIEXPORT
24442446
LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
24452447
if (InterceptOSException) return EXCEPTION_CONTINUE_SEARCH;
24462448
PEXCEPTION_RECORD exception_record = exceptionInfo->ExceptionRecord;

src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#define REG_PC Eip
6969
#endif // AMD64
7070

71+
JNIEXPORT
7172
extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
7273

7374
// Install a win32 structured exception handler around thread.

test/hotspot/gtest/gtestLauncher.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,23 @@
2323

2424
#include "jni.h"
2525

26+
#ifdef _WIN32
27+
#include <windows.h>
28+
#include <excpt.h>
29+
extern LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo);
30+
#endif
31+
2632
extern "C" {
2733
JNIIMPORT void JNICALL runUnitTests(int argv, char** argc);
2834
}
2935

3036
int main(int argc, char** argv) {
37+
#ifdef _WIN32
38+
__try {
39+
#endif
3140
runUnitTests(argc, argv);
41+
#ifdef _WIN32
42+
} __except(topLevelExceptionFilter(GetExceptionInformation())) {}
43+
#endif
3244
return 0;
3345
}

test/hotspot/jtreg/gtest/GTestWrapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public static void main(String[] args) throws Throwable {
8282
command.add("-jdk");
8383
command.add(Utils.TEST_JDK);
8484
command.add("--gtest_output=xml:" + resultFile);
85+
command.add("--gtest_catch_exceptions=0" + resultFile);
8586
for (String a : args) {
8687
command.add(a);
8788
}

0 commit comments

Comments
 (0)