Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(client/launcher): don't return dump when not done
See the related forum post:

    https://forum.cfx.re/t/4830833/2

Ideally, this'd provide some visible user feedback while 'crashing', but
this is out of scope right now.
  • Loading branch information
blattersturm committed Mar 26, 2022
1 parent 6d8fc89 commit 3447874
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions code/client/launcher/MiniDump.cpp
Expand Up @@ -1089,8 +1089,8 @@ void InitializeDumpServer(int inheritedHandle, int parentPid)
}
}

// *final* checkpoint for reading `info`
info = nullptr;
SetEvent(hDone);

std::map<std::wstring, std::wstring> parameters;
#ifdef GTA_NY
Expand Down Expand Up @@ -1199,6 +1199,15 @@ void InitializeDumpServer(int inheritedHandle, int parentPid)
}
}

// do *not* modify shouldTerminate past this point

// if we should terminate the game, wait before marking the dump as 'done'
// we can't do this before, as we haven't set shouldTerminate yet
if (!shouldTerminate)
{
SetEvent(hDone);
}

windowTitle = PRODUCT_NAME;
mainInstruction = PRODUCT_NAME L" has stopped working";

Expand Down Expand Up @@ -1278,7 +1287,9 @@ void InitializeDumpServer(int inheritedHandle, int parentPid)

if (shouldTerminate)
{
std::thread([csignature]()
auto hDoneRef = hDone;

std::thread([csignature, hDone = hDoneRef]()
{
HostSharedData<CfxState> hostData("CfxInitState");
HANDLE gameProcess = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION, FALSE, hostData->gamePid);
Expand Down Expand Up @@ -1330,6 +1341,10 @@ void InitializeDumpServer(int inheritedHandle, int parentPid)
}
}

// this only runs if shouldTerminate, right before termination (and after calling the terminate handler)
// if this is the game process crashing, we need to hold off on 'releasing' the dump until the last chance we get
SetEvent(hDone);

TerminateProcess(parentProcess, -2);
})
.detach();
Expand Down

0 comments on commit 3447874

Please sign in to comment.