Skip to content

Commit a7120e2

Browse files
author
Alex Menkov
committed
8311993: Test serviceability/sa/UniqueVtableTest.java failed: duplicate vtables detected
Reviewed-by: cjplummer, kevinw, dholmes
1 parent 5ebdf2d commit a7120e2

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/jdk.hotspot.agent/windows/native/libsaproc/sawindbg.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -399,8 +399,11 @@ static bool setImageAndSymbolPath(JNIEnv* env, jobject obj) {
399399
IDebugSymbols* ptrIDebugSymbols = (IDebugSymbols*)env->GetLongField(obj, ptrIDebugSymbols_ID);
400400
CHECK_EXCEPTION_(false);
401401

402-
ptrIDebugSymbols->SetImagePath(imagePath);
403-
ptrIDebugSymbols->SetSymbolPath(symbolPath);
402+
COM_VERIFY_OK_(ptrIDebugSymbols->SetImagePath(imagePath),
403+
"Windbg Error: SetImagePath failed!", false);
404+
COM_VERIFY_OK_(ptrIDebugSymbols->SetSymbolPath(symbolPath),
405+
"Windbg Error: SetSymbolPath failed!", false);
406+
404407
return true;
405408
}
406409

@@ -829,6 +832,8 @@ JNIEXPORT jstring JNICALL Java_sun_jvm_hotspot_debugger_windbg_WindbgDebuggerLoc
829832
return res;
830833
}
831834

835+
#define SYMBOL_BUFSIZE 512
836+
832837
/*
833838
* Class: sun_jvm_hotspot_debugger_windbg_WindbgDebuggerLocal
834839
* Method: lookupByName0
@@ -852,10 +857,22 @@ JNIEXPORT jlong JNICALL Java_sun_jvm_hotspot_debugger_windbg_WindbgDebuggerLocal
852857
if (ptrIDebugSymbols->GetOffsetByName(name, &offset) != S_OK) {
853858
return (jlong) 0;
854859
}
860+
861+
// See JDK-8311993: WinDbg intermittently returns offset of "module!class::`vftable'" symbol
862+
// when requested for decorated "class" or "class*" (i.e. "??_7class@@6B@"/"??_7class*@@6B@").
863+
// As a workaround check if returned symbol contains requested symbol.
864+
ULONG64 disp = 0L;
865+
char buf[SYMBOL_BUFSIZE];
866+
memset(buf, 0, sizeof(buf));
867+
if (ptrIDebugSymbols->GetNameByOffset(offset, buf, sizeof(buf), 0, &disp) == S_OK) {
868+
if (strstr(buf, name) == nullptr) {
869+
return (jlong)0;
870+
}
871+
}
872+
855873
return (jlong) offset;
856874
}
857875

858-
#define SYMBOL_BUFSIZE 512
859876
/*
860877
* Class: sun_jvm_hotspot_debugger_windbg_WindbgDebuggerLocal
861878
* Method: lookupByAddress0

0 commit comments

Comments
 (0)