Skip to content
Permalink
Browse files
8204994: SA might fail to attach to process with "Windbg Error: WaitF…
…orEvent failed"

Backport-of: 3dc78e7
  • Loading branch information
Ekaterina Vergizova authored and Yuri Nesterenko committed Jan 18, 2021
1 parent 13bd35a commit 7943806be796466a29f467a23c4d469d8be42b9b
Showing with 15 additions and 2 deletions.
  1. +15 −2 src/jdk.hotspot.agent/windows/native/libsaproc/sawindbg.cpp
@@ -396,6 +396,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);
@@ -411,7 +424,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;
@@ -448,7 +461,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;

1 comment on commit 7943806

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 7943806 Jan 18, 2021

Please sign in to comment.