4

In macOS, I find that SIGABRT won't generate core dumps in some cases.

For example, I run a sleep in one terminal:

lianxin.wlx@mbp [01:08:21] [~/test]
-> % sleep 1000

And send a SIGABRT to it in another terminal:

lianxin.wlx@mbp [01:08:59] [~]
-> % ps -ef | grep sleep
  502 47679 20388   0  1:08AM ttys001    0:00.01 sleep 1000
lianxin.wlx@mbp [01:09:03] [~]
-> % kill -6 47679

Then the sleep process is aborted, but no core dump is generated.

lianxin.wlx@mbp [01:08:21] [~/test]
-> % sleep 1000
[1]    47679 abort      sleep 1000
lianxin.wlx@mbp [01:10:35] [~/test]
-> % ls /cores
lianxin.wlx@mbp [01:10:37] [~/test]
-> %

So why? I've tested the same operations in Linux, it did generate a core dump.

I'm sure I've opened the core dump right(ulimit -c unlimited, and /cores's privilege is 777). I wrote a program that will crash with SIGSEGV, and it did generate a core dump in /cores.

user438383
  • 5,716
  • 8
  • 28
  • 43
Lixin Wei
  • 441
  • 5
  • 17

1 Answers1

0

If you make a simple program,

main() {
    abort();
}

It will generate a core dump if run with appropriate priv. Also, if you make a:

main() {
    sleep(100);
}

run it in the background and kill -ABRT , it will generate a core dump. But /bin/sleep doesn't, which is a bit odd.

This is assuming you have followed the recipe in man core.

mevets
  • 10,070
  • 1
  • 21
  • 33
  • I tried the second program, it won't generate core dumps. The first one will. – Lixin Wei Oct 27 '21 at 06:01
  • It does on my `Darwin Kernel Version 16.7.0: Wed Apr 24 20:50:53 PDT 2019; root:xnu-3789.73.49~1/RELEASE_X86_64` (Sierra). – mevets Oct 27 '21 at 13:57
  • mine is Darwin 20.6.0, MacOS BigSur 11.6 (20G165). Maybe it's related to the system version? – Lixin Wei Oct 28 '21 at 07:12
  • Does`man core` on your system shed any light? I was a bit surprised I had to run it as root to get it generate a core file. – mevets Oct 28 '21 at 12:09