Skip to content

Commit d2c32fa

Browse files
Lost Present Update
Fix to handle infinite complete/lost present loop. Also fix for exception when present start time comes AFTER terminate process event
1 parent 1a08500 commit d2c32fa

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

PresentData/PresentMonTraceConsumer.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,34 @@ void PMTraceConsumer::RemoveLostPresent(std::shared_ptr<PresentEvent> p)
20262026
{
20272027
VerboseTraceBeforeModifyingPresent(p.get());
20282028
p->IsLost = true;
2029-
CompletePresent(p);
2029+
2030+
if (p->IsCompleted) {
2031+
// Present is already completed but lost - simulate what Present_Stop would do
2032+
if (p->WaitingForPresentStop) {
2033+
VerboseTraceBeforeModifyingPresent(p.get());
2034+
p->WaitingForPresentStop = false;
2035+
2036+
// Remove from thread tracking since Present_Stop won't come
2037+
auto ii = mPresentByThreadId.find(p->ThreadId);
2038+
if (ii != mPresentByThreadId.end() && ii->second == p) {
2039+
mPresentByThreadId.erase(ii);
2040+
}
2041+
if (p->DriverThreadId != 0) {
2042+
auto jj = mPresentByThreadId.find(p->DriverThreadId);
2043+
if (jj != mPresentByThreadId.end() && jj->second == p) {
2044+
mPresentByThreadId.erase(jj);
2045+
}
2046+
}
2047+
2048+
// Make ready for dequeue
2049+
UpdateReadyCount(true);
2050+
}
2051+
// If not waiting for Present_Stop, it should already be cleaned up properly
2052+
}
2053+
else {
2054+
// Present is not completed yet - complete it normally
2055+
CompletePresent(p);
2056+
}
20302057
}
20312058

20322059
void PMTraceConsumer::CompletePresent(std::shared_ptr<PresentEvent> const& p)

PresentMon/OutputThread.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,15 @@ static void ProcessEvents(
985985
// Handle any process events that occurred before this present
986986
if (checkProcessTime) {
987987
while ((*processEvents)[processEventIndex].QpcTime < presentTime) {
988+
auto& processEvent = (*processEvents)[processEventIndex];
989+
990+
// If this is a termination event for the same process as the current present,
991+
// skip processing this termination to avoid removing the process info we need
992+
if (!processEvent.IsStartEvent && processEvent.ProcessId == presentEvent->ProcessId) {
993+
// Don't process this termination yet - we have a present from this process to handle first
994+
break;
995+
}
996+
988997
ProcessProcessEvent((*processEvents)[processEventIndex]);
989998
processEventIndex += 1;
990999
if (processEventIndex == processEventCount) {

0 commit comments

Comments
 (0)