Repository navigation
Description
When the server GC is enabled my application start crashing frequently.
Below is the win dgb analysis
Microsoft (R) Windows Debugger Version 10.0.20348.1 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.
Loading Dump File [D:\workspace\Investigation\20211220_coreclr\program.exe.110804\Bifrost.exe.110804.dmp]
User Mini Dump File with Full Memory: Only application data is available
Symbol search path is: srv*
Executable search path is:
Windows 10 Version 17763 MP (36 procs) Free x64
Product: Server, suite: TerminalServer DataCenter SingleUserTS
Edition build lab: 17763.1.amd64fre.rs5_release.180914-1434
Machine Name:
Debug session time: Wed Dec 15 21:53:19.000 2021 (UTC + 8:00)
System Uptime: 331 days 9:44:52.929
Process Uptime: 0 days 1:25:50.000
................................................................
................................................................
................................................................
.................................................
Loading unloaded module list
.
This dump file has an exception of interest stored in it.
The stored exception information can be accessed via .ecxr.
(1b0d4.14480): Access violation - code c0000005 (first/second chance not available)
For analysis of this file, run !analyze -v
ntdll!NtWaitForMultipleObjects+0x14:
00007fff`ed12fcd4 c3 ret
0:053> !analyze -v
-
* -
Exception Analysis * -
*
*** WARNING: Unable to verify checksum for program.exe
*** WARNING: Unable to verify checksum for libzmq.dll
Failed to request MethodData, not in JIT code range
KEY_VALUES_STRING: 1
Key : AV.Dereference
Value: NullClassPtr
Key : AV.Fault
Value: Read
Key : Analysis.CPU.mSec
Value: 11577
Key : Analysis.DebugAnalysisProvider.CPP
Value: Create: 8007007e on PT-LUFI
Key : Analysis.DebugData
Value: CreateObject
Key : Analysis.DebugModel
Value: CreateObject
Key : Analysis.Elapsed.mSec
Value: 12898
Key : Analysis.Init.CPU.mSec
Value: 562
Key : Analysis.Init.Elapsed.mSec
Value: 21200
Key : Analysis.Memory.CommitPeak.Mb
Value: 264
Key : Analysis.System
Value: CreateObject
Key : CLR.Engine
Value: CORECLR
Key : CLR.Version
Value: 6.0.21.52210
Key : Timeline.OS.Boot.DeltaSec
Value: 28633492
Key : Timeline.Process.Start.DeltaSec
Value: 5150
Key : WER.OS.Branch
Value: rs5_release
Key : WER.OS.Timestamp
Value: 2018-09-14T14:34:00Z
Key : WER.OS.Version
Value: 10.0.17763.1
Key : WER.Process.Version
Value: 3.4.0.118
ADDITIONAL_XML: 1
OS_BUILD_LAYERS: 1
NTGLOBALFLAG: 0
PROCESS_BAM_CURRENT_THROTTLED: 0
PROCESS_BAM_PREVIOUS_THROTTLED: 0
APPLICATION_VERIFIER_FLAGS: 0
CONTEXT: (.ecxr)
rax=0000026f39fc3000 rbx=0000026f39fc2300 rcx=0000000000000028
rdx=0000000000000000 rsi=0000000001440003 rdi=0000026f39fc2300
rip=00007fffb2d85ccb rsp=000000ea4ce7c4c0 rbp=0000000026f39fc1
r8=0000026f39fc3000 r9=0000000026f39fc2 r10=000000026f39fc3f
r11=0000000000000000 r12=0000026f39fc3e01 r13=0000026f39fc3e00
r14=0000026f39fc1d28 r15=00000275fde07fc0
iopl=0 nv up ei pl nz na po nc
cs=0033 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010206
coreclr!SVR::my_get_size+0xa [inlined in coreclr!SVR::gc_heap::find_first_object+0xd7]:
00007fffb2d85ccb 833900 cmp dword ptr [rcx],0 ds:0000000000000028=????????
Resetting default scope
EXCEPTION_RECORD: (.exr -1)
ExceptionAddress: 00007fffb2d85ccb (coreclr!SVR::my_get_size+0x000000000000000a)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 0000000000000000
Parameter[1]: 0000000000000028
Attempt to read from address 0000000000000028
PROCESS_NAME: Bifrost.exe
READ_ADDRESS: 0000000000000028
ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%p referenced memory at 0x%p. The memory could not be %s.
EXCEPTION_CODE_STR: c0000005
EXCEPTION_PARAMETER1: 0000000000000000
EXCEPTION_PARAMETER2: 0000000000000028
STACK_TEXT:
000000ea4ce7c4c0 00007fffb2d80d42 : 0000026f39fe12b8 000000ea4ce7c610 000000026f39fc3e 00000275fde07fc0 : coreclr!SVR::gc_heap::find_first_object+0xd7
000000ea4ce7c510 00007fffb2d661bc : 0000027500000001 00007fffb2d7e470 0000000000000000 00000275fde00ba0 : coreclr!SVR::gc_heap::mark_through_cards_for_segments+0x1e6
000000ea4ce7c6f0 00007fffb2d6184a : 0000000000000000 0000000000000000 00000275fde00ba0 00007fffb2d69211 : coreclr!SVR::gc_heap::mark_phase+0x61c
000000ea4ce7c7b0 00007fffb2d62fac : 0000000000000000 0000000000000000 00000275fde00ba0 00000000000008e0 : coreclr!SVR::gc_heap::gc1+0xb6
000000ea4ce7c820 00007fffb2d62a96 : 00000000000008e0 0000000000000000 0000000000000000 00000275fde00ba0 : coreclr!SVR::gc_heap::garbage_collect+0xec
000000ea4ce7c880 00007fffb2d62a30 : 00000275fde00ba0 000000ea4ce7fad0 000000ea4ad7ead0 0000000000000000 : coreclr!SVR::gc_heap::gc_thread_function+0x62
000000ea4ce7c8b0 00007fffb2e25fe4 : 0000000000000000 00000275fde00ba0 00007fffb2d62980 0000000000000000 : coreclr!SVR::gc_heap::gc_thread_stub+0xb0
000000ea4ce7fb00 00007fffeacf7974 : 0000000000000000 0000000000000000 0000000000000000 0000000000000000 : coreclr!<lambda_cb183d4f30cacb23ee8f0a2094f74691>::<lambda_invoker_cdecl>+0x74
000000ea4ce7fb30 00007fffed0ea0b1 : 0000000000000000 0000000000000000 0000000000000000 0000000000000000 : kernel32!BaseThreadInitThunk+0x14
000000ea4ce7fb60 0000000000000000 : 0000000000000000 0000000000000000 0000000000000000 0000000000000000 : ntdll!RtlUserThreadStart+0x21
FAULTING_SOURCE_LINE: D:\a_work\1\s\src\coreclr\gc\gc.cpp
FAULTING_SOURCE_FILE: D:\a_work\1\s\src\coreclr\gc\gc.cpp
FAULTING_SOURCE_LINE_NUMBER: 35423
SYMBOL_NAME: coreclr!SVR::gc_heap::find_first_object+d7
MODULE_NAME: coreclr
IMAGE_NAME: coreclr.dll
STACK_COMMAND: ~53s ; .ecxr ; kb
FAILURE_BUCKET_ID: NULL_CLASS_PTR_READ_c0000005_coreclr.dll!SVR::gc_heap::find_first_object
OS_VERSION: 10.0.17763.1
BUILDLAB_STR: rs5_release
OSPLATFORM_TYPE: x64
OSNAME: Windows 10
IMAGE_VERSION: 6.0.21.52210
FAILURE_ID_HASH: {336b3048-6228-039c-f897-490031da60b3}
Activity
Maoni0 commentedon Dec 23, 2021
sorry you are hitting this! I think @cshung is the only one from the GC team who's not on vacation right now so he might be able to take a look (since it's almost Christmas, realistically it probably will be next week). I'm aware of one bug in GC that can cause an AV that's fixed in the current master but not in 6.0. as you know, without investigation it's impossible to say if it caused what you saw or if what you saw is caused by GC or something else. would it be possible to share a dump/multiple dumps or even a repro? that would be very helpful.
cshung commentedon Dec 23, 2021
@harishrajput4, do we have a repro?
harishrajput4 commentedon Dec 24, 2021
HighPerfDotNet commentedon Dec 25, 2021
I might be hitting same thing, details: #63127
cshung commentedon Dec 27, 2021
Analyzing your call stack, it appears we are in a blocking ephemeral (i.e. gen 0 or gen 1) GC. (i.e.
gc1). We are walking the heap to try to find young objects that might be referenced by the old ones through the card table. (i.e.mark_through_cards_for_segments) The card table tells us which page is potentially dirty but does not tell us exactly where the references are, so we need to find them (i.e.find_first_object). To find an object, we need to know the size of an object (i.e.my_get_size) through the method table (which should NOT benull) and somehow we read anull. (i.e.rcx= 0)I would bet that somehow we are referencing a region of memory that is 0 and think there is an object there. This type of issue is what we called heap corruption, the memory content is wrong, but we don't know why we got there.
I had some experience nailing down some heap corruptions, for example, see here and here. The recurring key to solving these heap corruption issues is to realize that the act of corruption happened in the past, so we need to drill into the history of the process, and we can do that through extensive logging of repeated runs. A crash dump is often insufficient for the purpose since the act of corruption might have happened long ago before the time we crashed.
That is why a reliable repro is so important. Without being able to reproduce the problem, there is not much hope to figure out what was wrong.
Unfortunately, you cannot share the repro with us. But that's okay, at least you can still repro on your side. While I couldn't draw the dots between your symptom and #60966, but it wouldn't hurt to at least try to apply the fix on release/6.0 and see if that make a difference. If that doesn't work out, let's meet, I can tell you how to turn on the stress logging and start doing some debugging, would that work for you?
HighPerfDotNet commentedon Dec 27, 2021
Will this fix get release as part of 6.0.2 next month? In my case crash does NOT happen in .NET 5.0.13.
cshung commentedon Dec 27, 2021
It is too early to say anything about releasing the fix for this issue yet, as we don't still know what the root cause is.
From my experience, whether or not releasing a fix back into an already released product depends on these factors.
Whether or not the bug is hurting (i.e. the frequency and severity of the bug). I personally think this bug does meet this criterion since it is crashing a few times a day.
Whether or not the fix is breaking (i.e. some application might leverage the bug). I personally think this bug is unlikely to be leveraged for any good purpose, and
Whether or not the fix is risky (i.e. it might bring in some new bugs). Now without knowing what the root cause is, we have no idea what the fix would be, so it is very hard to foresee this one.
So, if I were to predict, if we found a fix for this one, there is a high likelihood that we will release the fix for .NET 6.
That being said, given we have no idea what is going on and I cannot access your repro, it would be great if you (@HighPerfDotNet ) could help us with this investigation. If you think your case is potentially the same issue, maybe you can try the same advice above and see what happens for you.
HighPerfDotNet commentedon Dec 27, 2021
When talking about 6.0.2 I meant this fix - #60966
I am inclined to think that I am also running into the same problem (I've added windbg output to my issue that seems very similar if not the same).
I fully appreciate the difficulty in debugging such a tough case remotely with repro - would not have liked to be on receiving end of such reports...
Sadly I can't see how I could provide a repro - app too large (and confidential) and it happens when processing lots of data (in range of 100 GBytes range).
I am going use .NET 5 for now that does not crash and wait till fix for is released next, at that point I'll try again and report back, fingers crossed.
cshung commentedon Dec 27, 2021
The thing with #60966 is that we don't know if that fixes the problem. Releasing a fix is a relatively expensive process, so it would be really nice if we can try the fix out before we decide to release it. Is there something blocking you from trying out the fix without having us formally releasing that yet? I assume you can clone the source, make a build, patch, and run with the fix enabled?
HighPerfDotNet commentedon Dec 27, 2021
I would be very happy to try the fix, but my skills are well below doing what you asking me to do (clonig/etc), however if you give me a binary installer (or some simple instructions how to install new net core binaries) that includes the fix then I am prepared to try it, can talk details via email if it helps.
cshung commentedon Dec 28, 2021
@HighPerfDotNet. I totally understand that building and patching CoreCLR is not something that everybody knows how to do. Here are some instructions on how one can do this. I intend to eventually check this in so that I can refer future users to this. Let me know if anything below confuses you so that I can improve that writing.
Building and cherry-picking are indeed non-trivial because of the potential merge conflicts and require prerequisites installation. Still, I encourage you to try. But if it is really difficult, I can do that for you. Before that though, I do need to know your CoreCLR exact commit hash, and the included instruction below detailed how to obtain that.
Patching CoreCLR
CoreCLR can have bugs, and it would be very sad if our user needs to wait until the fixes are released before they can validate their scenario. Therefore, this document is written to, as clearly as possible, the procedure for testing out a fix in CoreCLR in their applications.
Testing CoreCLR is not new, we already have this, this and this document covering the various ways we can use a built CoreCLR. These documents all assume we are using the CoreCLR to run some HelloWorld for targeted testing.
In real life, our users run much more complicated stuff than just Hello World, with many dependencies, and things can get tricky with these configurations. This document attempts to summarize some of the best practices for handling such a situation.
For now, the document is Windows only. Feel free to contribute to writing the Unix equivalent.
Goal
To test a fix in the CoreCLR safely with minimal changes possible. To do so, we will attempt to apply exactly one change to the current binary and make sure only one executable project gets updated.
Determine the executable
.NET 5.0 or .NET 6.0 are nice easily memorizable names for a .NET version, but it isn't precise. With the same version, we have multiple patches. For whatever reason, not all users running the latest patch, so we must be careful on exactly what build we are talking about.
First, figure out which process we would like to run the CoreCLR. Most of the time, the process can be easily recognized because the name of the executable is exactly the same as your project. For example, if you have a HelloWorld console application, then your process is
HelloWorld.exe.Determine the current version
There are multiple ways you can figure out the CoreCLR version given the process. The easiest way is by attaching the Debugging Tools for Windows to the process. This will stop the process, and then you can run the following command:
Then you should see something like this, with the path and the Commit Hash shown
The path indicates where the process loaded the CoreCLR from, and the commit hash indicates the exact version of the CoreCLR.
If you cannot afford to stop the process, you can still use SysInternals Process Explorer to find the process. Change the Show Lower Pane view to DLL allows you to look at the loaded modules. CoreCLR.dll should be there, which should show you the full path to the binary. Double-clicking that will show you a property window, the commit hash can be found in the String tab. This approach is a bit more complicated, but it doesn't stop the process.
Isolating the change
In our example, the binary loaded is in a shared directory. Modifying a shared binary is a bad idea, as that is going to impact all processes on the machine using the binary. If possible, the best practice is to use the self-contained deployment option, this way the CoreCLR will be exclusively used by just the project and nothing else. Check this out for the self-contained deployment option and see how you can use that. This advice does not intend to mean self-contained deployment is better. It merely meant this can reduce the risk for testing purposes only, and of course, we can roll back to the shared deployment when we are done.
Cherry Picking the fix
To apply the fix to that particular version, we can cherry-pick the fix. Cherry-picking a particular fix to a particular version is a standard Git practice, so readers are referred to read this tutorial instead.
Building the binary
Building the CoreCLR is very well documented here. Make sure we keep the whole build,, but in particular these files are important.
Patching
Once we have the new binary, we are certain that the binary contains exactly what it was together with the fix. It should be safe for us to replace the binary.
Make sure we:
Almost done
Once the file is replaced, we can run the process as usual. It should run the new version of CoreCLR.dll. Since we know how to find the process and the binary, we should be able to validate that.
Last step
Restore back to the original version. Even when the patched version work, it is privately built and there is no easy way to support it. It is advised that the patched binary should never be used as a solution for production usage.
HighPerfDotNet commentedon Dec 28, 2021
Thanks for detailed info, but I am afraid I don't have mental bandwidth to attempt right now custom build, so your help doing it would be appreciated - I am very keen to get .NET 6 running well as my testing shows nice speedups that I'd like to get.
I think there might be easier way of getting that has, by just checking C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.0\ (which is highest I am testing right now, downgraded from 6.0.1 to see if it helped avoid crash), hash there in file .version - 4822e3c - exactly the same as the one you've listed. Double checking with Explorer's right click on Details I get the same version in that DLL - sorry by using less hardcore method to check it, hope that gives same results.
If it is easier for you to get build for 6.0.1 then I can install it also on test box (the hash would be: 3a25a7f ), this one probably best to test out I reckon, as it's current
harishrajput4 commentedon Dec 29, 2021
Thanks for you investigation and suggestion, i am on vacation now but my colleague is working on it, After my vacation i will try create a separate repo (it might be difficult to create a scenario with similar issue), also we will try to test as per your suggestion.
cshung commentedon Dec 29, 2021
Here is a build of 4822e3c with the fix for #60966 applied on top.
To check for the integrity of the files, use the Get-FileHash cmdlet, the hash should be identical.
The source branch used to create the build is shared here.
HighPerfDotNet commentedon Dec 29, 2021
Thank you very much - I've put patched binaries into small one system that was consistently crashing in one part of processing: it's too early to be 100% sure, but the first cycle finished without crash, I'll let it run and report tomorrow!
HighPerfDotNet commentedon Dec 30, 2021
FIX WORKED! :)
Not a single crash, including in a bigger test which had multiple crashes in the same run
Do you want me to test patch for 6.0.1? If not I am going to roll out to more servers.
Also, was that patch made with release build quality for speed or debug?
cshung commentedon Dec 31, 2021
Good news indeed - get me the hash for your 6.0.1, I can get you a patched build just like we had before.
The binary I shared is built in the release configuration.
HighPerfDotNet commentedon Dec 31, 2021
Still no crashes, all good! Hash for 6.0.1 is 3a25a7f
Happy New Year and thanks for great support during holiday period!
cshung commentedon Jan 3, 2022
Here is a build of 3a25a7f with the fix for #60966 applied on top.
To check for the integrity of the files, use the Get-FileHash cmdlet, the hash should be identical.
The source branch used to create the build is shared here.
harishrajput4 commentedon Jan 4, 2022
We are also testing the, no crash in last 24 hours, we are planning to test it on more machines.
I hope this fix will work for us. I will post here in case of any issue.
Thanks for quick and great support
cshung commentedon Jan 4, 2022
It appears that the fix does help with the situation. I am going to work with our management to get this into the next eligible servicing release. A PR #63351 is created for the backporting.
@mangod9
HighPerfDotNet commentedon Jan 5, 2022
Awesome! I've patched 6.0.1 and deployed onto a lot more servers, that should be pretty much ultimate test as far as I am concerned. Will report if I see any more crashes, hopefully not!
cshung commentedon Jan 6, 2022
The fix is backported to release/6.0, it will be available in our next servicing release. Closing for now.