Skip to content

Commit 709fcd8

Browse files
authored
StressLogAnalyzer didn't print the number of messages correctly if it exceeded the int range (2 billion). (#54832)
Fix is to just use 64 bit ints instead.
1 parent d00b018 commit 709fcd8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/coreclr/tools/StressLogAnalyzer/StressLogPlugin/StressLogPlugin.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,8 @@ static LONG s_wrappedWriteThreadCount;
544544

545545
static const LONG MAX_MESSAGE_COUNT = 64 * 1024 * 1024;
546546
static StressThreadAndMsg* s_threadMsgBuf;
547-
static volatile LONG s_msgCount = 0;
548-
static volatile LONG s_totalMsgCount = 0;
547+
static volatile LONGLONG s_msgCount = 0;
548+
static volatile LONGLONG s_totalMsgCount = 0;
549549
static double s_timeFilterStart = 0;
550550
static double s_timeFilterEnd = 0;
551551
static wchar_t* s_outputFileName = nullptr;
@@ -988,7 +988,7 @@ bool ParseOptions(int argc, wchar_t* argv[])
988988

989989
static void IncludeMessage(uint64_t threadId, StressMsg* msg)
990990
{
991-
LONG msgCount = _InterlockedIncrement(&s_msgCount) - 1;
991+
LONGLONG msgCount = _InterlockedIncrement64(&s_msgCount) - 1;
992992
if (msgCount < MAX_MESSAGE_COUNT)
993993
{
994994
s_threadMsgBuf[msgCount].threadId = threadId;
@@ -1133,7 +1133,7 @@ DWORD WINAPI ProcessStresslogWorker(LPVOID)
11331133
s_threadStressLogDesc[threadStressLogIndex].workFinished = 1;
11341134
}
11351135

1136-
InterlockedAdd(&s_totalMsgCount, totalMsgCount);
1136+
InterlockedAdd64(&s_totalMsgCount, totalMsgCount);
11371137
InterlockedAdd(&s_wrappedWriteThreadCount, wrappedWriteThreadCount);
11381138

11391139
return 0;
@@ -1151,7 +1151,7 @@ static double FindLatestTime(StressLog::StressLogHeader* hdr)
11511151
return latestTime;
11521152
}
11531153

1154-
static void PrintFriendlyNumber(int n)
1154+
static void PrintFriendlyNumber(LONGLONG n)
11551155
{
11561156
if (n < 1000)
11571157
printf("%d", n);

0 commit comments

Comments
 (0)