Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
8204994: SA might fail to attach to process with "Windbg Error: WaitF…
Browse files Browse the repository at this point in the history
…orEvent failed"

Backport-of: 3dc78e7
  • Loading branch information
Ekaterina Vergizova authored and Yuri Nesterenko committed Jan 18, 2021
1 parent 13bd35a commit 7943806
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/jdk.hotspot.agent/windows/native/libsaproc/sawindbg.cpp
Expand Up @@ -396,6 +396,19 @@ static bool setImageAndSymbolPath(JNIEnv* env, jobject obj) {
return true; 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) { static bool openDumpFile(JNIEnv* env, jobject obj, jstring coreFileName) {
// open the dump file // open the dump file
AutoJavaString coreFile(env, coreFileName); AutoJavaString coreFile(env, coreFileName);
Expand All @@ -411,7 +424,7 @@ static bool openDumpFile(JNIEnv* env, jobject obj, jstring coreFileName) {


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


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


return true; return true;
Expand Down

1 comment on commit 7943806

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.