fixed VirtualMemoryLogging::logRecords overflow (#308)
authorQin Li <qin.li@thetradedesk.com>
Tue, 3 Dec 2019 23:23:10 +0000 (15:23 -0800)
committerJan Vorlicek <janvorli@microsoft.com>
Tue, 3 Dec 2019 23:23:10 +0000 (00:23 +0100)
commit58a4330a712fe27d3af6aee16817f9f1ad876343
tree2db9a9ecd0b6e79d731b83979436e363f1a93c7b
parent8bdcba1b0e572ac02d618f9ed1adcabb24839f05
fixed VirtualMemoryLogging::logRecords overflow (#308)

when VirtualMemoryLogging::recordNumber increments from LONG_MAX,
it became negative number, and the result of i % MaxRecords became
a number from -127 to 0.

When that happens we will ovewrite CRITICAL_SECTION virtual_critsec
which are stored in bss right before logRecords with garbage data.
Then most likely the process will have a GC hang with one or more
GC threads stuck trying to enter or leave critical section.

The fix is to ensure ULONG value are passed to modulo operation.
src/coreclr/src/pal/src/map/virtual.cpp