Skip to content

fixed VirtualMemoryLogging::logRecords overflow - #308

Merged
janvorli merged 1 commit into
dotnet:masterfrom
thetradedesk:fix_vmlog_overflow
Dec 3, 2019
Merged

janvorli merged 1 commit into
dotnet:masterfrom
thetradedesk:fix_vmlog_overflow

Conversation

@tqinli

@tqinli tqinli commented Nov 26, 2019

Copy link
Copy Markdown
Contributor

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.

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.
@tqinli

tqinli commented Nov 26, 2019

Copy link
Copy Markdown
Contributor Author

@janvorli I ported the fix here, compiled locally both debug and release which had passed as expected. Can you take an other look?

@maryamariyan maryamariyan added the area-PAL-coreclr only for closed issues label Nov 26, 2019

@janvorli janvorli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thank you!

@tqinli

tqinli commented Dec 3, 2019

Copy link
Copy Markdown
Contributor Author

@janvorli wondering if there is anything I needed to do for this? Or when can we have this fix merged into latest .net core?

@janvorli

janvorli commented Dec 3, 2019

Copy link
Copy Markdown
Member

@tqinli I was just waiting for the CI to pass. I have also created a PR for porting the change to release/3.1 that was approved.

@janvorli
janvorli merged commit 58a4330 into dotnet:master Dec 3, 2019
@tqinli

tqinli commented Dec 3, 2019

Copy link
Copy Markdown
Contributor Author

@janvorli great to hear! thanks for your help and getting this port to 3.1!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-PAL-coreclr only for closed issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants