How to test core dump creation (createdump) for .NET Core macOS app?

130 Views Asked by At

I have a .NET Core application for which I am enabling minidump as follows:

<MonoBundlingExtraArgs>--setenv:COMPlus_DbgEnableMiniDump=1 --setenv:COMPlus_EnableCrashReport=1 --setenv:COMPlus_EnableDumpOnSigTerm=1</MonoBundlingExtraArgs>

Now, when I launch my app and then send it a SEGV signal through

kill -s SEGV <pid>

The app crashes, but I don't see a coredump or a crashreport.json. I have also tried force quitting the app, but still don't see a core dump or crash report.

I have also tried creating a simple C library with a method that will create a segfault:

#include <stdio.h>

void trigger_crash() {
    int *ptr = NULL;
    *ptr = 42; // This will likely cause a segmentation fault
}

Then I build this library to produce a dylib. I then create a C# wrapper around it as follows:

public class SigHandler {
    [DllImport("handler", CallingConvention = CallingConvention.Cdecl)]
    public static extern void trigger_crash(string appName, int length);

    public void TriggerSegfault() {
      trigger_crash()
    }
}

I copy over the dylib to the MonoBundle in the build and then I call the above C# TriggerSegfault method from the managed code to trigger a segfault on a button click. Still, I don't get any core dumps or crash report.

However, if I just have a simple Debug.Assert(false, "Some statement"), I see the coredump and the crash report being created.

Can anyone please help me understand where I am going wrong? And if possible, what is the correct way to test a native crash that will create a coredump? Thanks!

0

There are 0 best solutions below