Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Dump a .NET Core Application on Linux

I have a .NET application that I have ported to .NET Core. I am testing it on Ubuntu 14.04.

I am trying to figure out how to get a .dmp file or the Linux equivalent when the program crashes. I call Environment.FailFast but as far as I can tell this doesn't generate a .dmp file like it does on Windows. Acording to this case Environment.FailFast should be creating a dump but if it is I can't find it.

In addition I have tried manually creating a dump using gcore. This works however it takes a long time to generate the dump (my application isn't that big) and I am unable to get the correct callstacks in gdb after the fact as when I point gdb to my application dll it doesn't recognize it.

What it he best way to get a dump of a .NET Core application on Linux?

Thanks!

like image 307
shortspider Avatar asked Sep 06 '25 03:09

shortspider


1 Answers

The generation of linux coredumps is defined by what's in /proc/sys/kernel/core_pattern. If certain signals (e.g. SIGSEGV or SIGQUIT) cause a process to terminate, an image of the process's memory is basically written into that file. If it starts with a pipe-symbol |, it can be streamed into an application which does dump analysis. It's documented here: http://man7.org/linux/man-pages/man5/core.5.html

If you configure it like that:

   echo coredump > /proc/sys/kernel/core_pattern

it will write a file named coredump into the current directory.

If you configure it like that:

   echo "/tmp/cores/core.%e.%p.%h.%t" > /proc/sys/kernel/core_pattern

It will create a file like /tmp/cores/core.bash.8539.drehbahn-mbp.1236975953 (see https://sigquit.wordpress.com/2009/03/13/the-core-pattern/)

As others suggested, also set ulimit -S -c unlimited to allow coredumps of any size.

Here is a blog-post which shows how to create and analyze .NET Core coredumps under linux: http://blogs.microsoft.co.il/sasha/2017/02/26/analyzing-a-net-core-core-dump-on-linux/

like image 60
chrisn Avatar answered Sep 07 '25 23:09

chrisn