How to allow application cores in Big Sur

How do I enable core dumps, persistently, in Big Sur.

I am more versed in *nix/linux than macOS. I've had a few apps core dump, and see in the 'Console' that they are not permitted to create core files.

I've tried 'ulimit -c unlimited' but this hasn't been perspective - perhaps in part as I'm unsure how to get this persistent for all apps (even outside a login shell) on Big Sur.

Is there a simple guide to allowing core dumps ie into /cores as I was able to get that working in previous releases...

Replies

The /cores directory is only writable by root:

Code Block
% ls -ld /cores
drwxr-xr-x 3 root wheel 96 26 Feb 10:34 /cores


So you only get a core dump when the process is running as root:

Code Block
% ulimit -c unlimited
% ./crash
zsh: abort ./crash
% ls -lha /cores
total 0
drwxr-xr-x 2 root wheel 64B 13 Dec 2019 .
drwxr-xr-x 20 root wheel 640B 1 Jan 2020 ..
% # No core!
%
% sudo ./crash
% ls -lha /cores
total 4900984
drwxr-xr-x 3 root wheel 96B 26 Feb 10:34 .
drwxr-xr-x 20 root wheel 640B 1 Jan 2020 ..
-r-------- 1 root wheel 2.3G 26 Feb 10:35 core.21226
% # Now we get a core.


You can change the owner and permissions of /cores if you want:

Code Block
% sudo chown :staff /cores
% sudo chmod g+w /cores
% ls -ld /cores
drwxrwxr-x 2 root staff 64 Jan 1 2020 /cores


Personally I only do this in a VM. I prefer not to make system-wide configuration changes on my main Mac.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
  • Which doesn't work for me. This recipe worked on the previous machine (MacOS 10.13.6, MacBook Pro (15-inch, 2017)

    The current machine MacOS 11.4, MacBook Pro (13-inch, M1, 2020)

    % ls -ld /cores

    drwxrwxrwt  2 root  staff  64 10 Jun 15:15 /cores

    [ant-5:~/git/bind9] marka% limit

    cputime      unlimited

    filesize     unlimited

    datasize     unlimited

    stacksize    8176 kbytes

    coredumpsize unlimited

    memoryuse    unlimited

    descriptors  256 

    memorylocked unlimited

    maxproc      2666 

    [ant-5:~/git/bind9] marka% ./a.out

    Segmentation fault

    % ls -l /cores

    % sysctl -a | grep core

    kern.corefile: /cores/core.%P

    kern.coredump: 1

    kern.sugid_coredump: 0

    machdep.cpu.core_count: 8

    machdep.cpu.cores_per_package: 8

Add a Comment

I have tried 'ulimit -c unlimited' and couple of other things mentioned in various forums. I have checked that /cores folder has write permissions. Still I couldn't manage to generate the core dumps for the crash on macOS bigsur 11.5.2. @eskimo Can you please list the steps required to enable the core dump on macOS bigsur 11.5.2 ?

more info from my machine

kern.corefile: /cores/core.%P
kern.coredump: 1
kern.sugid_coredump: 0
machdep.cpu.thermal.core_power_limits: 1
machdep.cpu.core_count: 8
machdep.cpu.cores_per_package: 8
launchctl limit                                                                                                                                                                                                                                                        
	cpu         unlimited      unlimited
	filesize    unlimited      unlimited
	data        unlimited      unlimited
	stack       8388608        67104768
	core        0              unlimited
	rss         unlimited      unlimited
	memlock     unlimited      unlimited
	maxproc     5568           8352
drwxrwxrwx   2 root  staff    64B Oct 20 19:21 cores