Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8204994: SA might fail to attach to process with "Windbg Error: WaitF…
…orEvent failed"

Reviewed-by: sspitsyn, cjplummer
  • Loading branch information
Alex Menkov committed Jun 2, 2020
1 parent 453f6cf commit 3dc78e76e4ec70406b337965e58be59bd9e6c8aa
Showing with 15 additions and 2 deletions.
  1. +15 −2 src/jdk.hotspot.agent/windows/native/libsaproc/sawindbg.cpp
@@ -398,6 +398,19 @@ static bool setImageAndSymbolPath(JNIEnv* env, jobject obj) {
return true;
}

static HRESULT WaitForEvent(IDebugControl *ptrIDebugControl) {
HRESULT hr = ptrIDebugControl->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE);
// see JDK-8204994: sometimes WaitForEvent fails with E_ACCESSDENIED,
// but succeeds on 2nd call.
// To minimize possible noise retry 3 times.
for (int i = 0; hr == E_ACCESSDENIED && i < 3; i++) {
// yield current thread use of a processor (short delay).
SwitchToThread();
hr = ptrIDebugControl->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE);
}
return hr;
}

static bool openDumpFile(JNIEnv* env, jobject obj, jstring coreFileName) {
// open the dump file
AutoJavaString coreFile(env, coreFileName);
@@ -413,7 +426,7 @@ static bool openDumpFile(JNIEnv* env, jobject obj, jstring coreFileName) {

IDebugControl* ptrIDebugControl = (IDebugControl*)env->GetLongField(obj, ptrIDebugControl_ID);
CHECK_EXCEPTION_(false);
COM_VERIFY_OK_(ptrIDebugControl->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE),
COM_VERIFY_OK_(WaitForEvent(ptrIDebugControl),
"Windbg Error: WaitForEvent failed!", false);

return true;
@@ -450,7 +463,7 @@ static bool attachToProcess(JNIEnv* env, jobject obj, jint pid) {
IDebugControl* ptrIDebugControl = (IDebugControl*) env->GetLongField(obj,
ptrIDebugControl_ID);
CHECK_EXCEPTION_(false);
COM_VERIFY_OK_(ptrIDebugControl->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE),
COM_VERIFY_OK_(WaitForEvent(ptrIDebugControl),
"Windbg Error: WaitForEvent failed!", false);

return true;

0 comments on commit 3dc78e7

Please sign in to comment.