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?

4
  • I was able to reproduce the problem on my Bigsur macbook air too...
    – Shai Almog
    Jan 10, 2022 at 7: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, 2022 at 9: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, 2022 at 2:53
  • I think all information from your comments should be added to the question.
    – Bodo
    Jan 11, 2022 at 8:55

1 Answer 1

7
+200

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
    
7
  • 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, 2022 at 14:52
  • @ShaiAlmog Expanded the answer. Jan 17, 2022 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, 2022 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? Jan 17, 2022 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, 2022 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.