I've been banging my head against this for a while. Obviously read this: Where are core dumps written on Mac?
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?
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
:
Make a copy first. Required since cat
is on a read-only filesystem.
% cp $(which cat) cat-copy
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
Re-sign cat-copy
with those entitlements:
% codesign -s - -f --entitlements tmp.entitlements cat-copy
CrashSelf: replacing existing signature