8

I've been banging my head against this for a while. Obviously read this: Where are core dumps written on Mac?

And this which lead to this.

Just so we're 100% clear:

I did:

touch  /cores/x
rm /cores/x

So write permission is good.

Did

ulimit -c unlimited

So cores should be generated.

But even a trivial:

sleep 100 & killall -SIGSEGV sleep

Doesn't generate a core. My current bet is that one of the filesystem protection features of the OS is giving me grief. Another possibility is that this is related to ARM (Running on an M1 Max).

Any ideas are very welcome... I even tried this unsuccessfully: (Mac) leave core file where the executable is instead of /cores?

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • I was able to reproduce the problem on my Bigsur macbook air too... – Shai Almog Jan 10 '22 at 07:21
  • I don't have a mac, so I can only give general advice. Did you check the `sysctl` variable `kern.coredump` mentioned in the answers to the linked question? – Bodo Jan 10 '22 at 09:05
  • Thanks, yes I tried that too. It's really weird, I tried on a 3rd even older machine and nothing... – Shai Almog Jan 11 '22 at 02:53
  • I think all information from your comments should be added to the question. – Bodo Jan 11 '22 at 08:55

1 Answers1

7

I'm currently on Mac OS Monterey. The solution suggested at https://developer.apple.com/forums/thread/694233?answerId=695943022#695943022 worked for me.

A quick summary: it is now necessary to enable com.apple.security.get-task-allow entitlement per executable.

Example with cat:

  1. Make a copy first. Required since cat is on a read-only filesystem.

    % cp $(which cat) cat-copy
    
  2. Create a dummy .entitlements with the com.apple.security.get-task-allow entitlement set:

    % /usr/libexec/PlistBuddy -c "Add :com.apple.security.get-task-allow bool true" tmp.entitlements
    File Doesn't Exist, Will Create: tmp.entitlements
    
  3. Re-sign cat-copy with those entitlements:

    % codesign -s - -f --entitlements tmp.entitlements cat-copy 
    CrashSelf: replacing existing signature
    
Nick Zavaritsky
  • 1,429
  • 8
  • 19
  • How can I enable it on `cat`? It isn't a .app bundle and I don't sign it. In my case this is for Java which I didn't sign – Shai Almog Jan 17 '22 at 14:52
  • @ShaiAlmog Expanded the answer. – Nick Zavaritsky Jan 17 '22 at 16:25
  • Trying `./cat-copy` I get: `No matching processes belonging to you were found fish: Job 1, './cat-copy &' terminated by signal SIGSEGV (Address boundary error)` – Shai Almog Jan 17 '22 at 16:54
  • Looks like you’ve started cat-copy in the background and killed it with SIGSEGV. We’re there a core file produced? Could you please stat /cores and share the output? – Nick Zavaritsky Jan 17 '22 at 17:34
  • It looks like the copy is broken. This is the output of stat `16777232 26194 drwxrwxr-t 2 shai staff 0 64 "Jan 9 16:10:27 2022" "Jan 9 16:07:07 2022" "Jan 10 09:10:19 2022" "Sep 18 09:26:54 2021" 4096 0 0x8000 /cores` – Shai Almog Jan 17 '22 at 20:35
  • `./cat-copy` results in: `fish: Job 1, './cat-copy' terminated by signal SIGKILL (Forced quit)` – Shai Almog Jan 17 '22 at 20:36
  • While I couldn't get it to work I still awarded the bounty before expiry since you made an effort. Thanks for the help and if you have an idea that would be great! – Shai Almog Jan 18 '22 at 18:16