-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected coredumps #10299
Comments
Hmm, why not? The program basically crashed due to an unhandled exception. |
I understand the rationale for having coredumps for unhandled exceptions. I noticed these coredumps while doing some ASP.NET Core stuff. When I forgot to close the previous app, the new one would crash with an exception:
and generate a coredump because the exception is unhandled. CC @davidfowl |
Yes, the runtime is behaving exactly as designed. An unhandled managed exception will call abort() generating a core dump if enabled. |
Maybe this issue is more about an specific part of .NET Core (i.e. ASP.NET) and maybe it needs a try/catch somewhere. |
I'll create an issue in the appropriate repo.
I understand the rationale, still the behavior came as a surprise. I think it's worth mentioning this explicitly in the docs. How does Windows behave in this case? Is there some event logged? Coredump created? Is there a way to control this? |
Whether a core dump is generated is dependent on your Linux configuration. Usually you have to explicitly add something like this to /etc/sysctl.conf
kernel.core_uses_pid = 1
kernel.core_pattern = /tmp/core-%e-%s-%u-%g-%p-%t
fs.suid_dumpable = 2
run “sudo sysctl -p” and then in the shell the app is run in run “ulimit -c unlimited”.
Once Linux is configurated to generate dumps any program or app (not just .NET Core app) that executes a abort() will generate a core dump.
FYI, .NET Core does have it’s own mechanism to generate mini-dump like core dumps automatically but it is also completely opt-in:
https://github.com/dotnet/coreclr/blob/master/Documentation/botr/xplat-minidump-generation.md
On Windows, generating a mini-dump depends also on how it and WER is configured (I don’t know the details though).
|
I need to check if Fedora generates coredumps by default or if this is something I configured (and forgot about). I'll do a clean install in a VM somewhere next week. |
Seems we can close this @tmds? |
@danmosemsft I don't think it's desirable to have coredumps by default, so I want to check the behavior on Fedora. I think we should also cover this in official docs (if it isn't already). For ASP.NET Core behavior, I've created a separate issue. |
On Fedora, coredumps are enabled by default. The OS also automatically removes old coredumps to save disk space. It's important we improve the docs so devs know how .NET Core behaves in case of unhandled exceptions. |
@tommcdon You probably meant to assign @mikem8361 😁 |
Based on what I said earlier, I think this can be converted to a 'documentation' issue. |
.NET Core's behavior is different from other stacks when it comes to unhandled exceptions. I understand the rationale for calling abort on unhandled exceptions. @mikem8361 wdyt? CC @halter73 |
.NET Core uses abort() (or TerminateProcess on Windows) when an unhandled exception occurs which is consistent behavior access all our supported platforms. It is just that the Fedora Linux distro has a default default (or your Fedora configuration does) whether is generates a core dump or not. We support 10 other Linux distros/versions that most of them don't. We obviously can't change the default now after releasing 1.x, 2.0 and 2.1 with this behavior. Adding an environment var for just this distro doesn't seem like solution when you can turn off core dump generation in Fedora just as easy as "ulimit -c 0". Also, the Fedora 28 docker image we use for building doesn't seem to have the /etc/sysctl.conf set to generate dumps so I think it is how your fedora VM is configured by default. |
Fedora uses systemd-coredump to manage coredumps. It is the default configuration. Maybe other distos are also using this or considering to adopt it. How the platform behaves for unhandled exceptions sets an expectation for the developers. With the current behavior, devs should catch exceptions and convert them to non-zero exit codes. The asp.net core templates are not doing this and probably that is not exceptional. |
I'm closing this because this is not likely to change. Given this issue, I'm a fan of the System.CommandLine |
I notice my system was creating coredumps for .NET Core processes.
Repro:
Running this will cause a coredump (
abort
called).I didn't expect this program to generate a coredump.
The text was updated successfully, but these errors were encountered: