Where are core dumps written on Mac?

MacosUnixSignalsCoredump

Macos Problem Overview


On Mac OS X, if I send SIGQUIT to my C program, it terminates, but there is no core dump file.

Do you have to manually enable core dumps on Mac OS X (how?), or are they written to somewhere else instead of the working directory?

Macos Solutions


Solution 1 - Macos

It seems they are suppressed by default. Running

$ ulimit -c unlimited

Will enable core dumps for the current terminal, and it will be placed in /cores as core.PID. When you open a new session, it will be set to the default value again.

Solution 2 - Macos

On macOS, your crash dumps are automatically handled by Crash Reporter.

You can find backtrace files by executing Console and going to User Diagnostic Reports section (under 'Diagnostic and Usage Information' group) or you can locate them in ~/Library/Logs/DiagnosticReports.

You can also check where dumps are generated by monitoring system.log file, e.g.

tail -f /var/log/system.log | grep crash

The actual core dump files you can find in /cores.

See also:

Solution 3 - Macos

Additionally, the /cores directory must exist and the user running the program must have write permissions on it.

Solution 4 - Macos

The answer above,

> ulimit -c unlimited

works -- but be sure to run that in the same terminal from which you will run the program that dumps core. You need to run the ulimit command first.

Solution 5 - Macos

by default, specific directories in mac osx are hidden. you might want to enable this feature in the terminal and then the core dump should be visible within the directory /cores. > defaults write com.apple.finder AppleShowAllFiles TRUE

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionxyzView Question on Stackoverflow
Solution 1 - MacosxyzView Answer on Stackoverflow
Solution 2 - MacoskenorbView Answer on Stackoverflow
Solution 3 - Macosuser666406View Answer on Stackoverflow
Solution 4 - MacosJoshua RichardsonView Answer on Stackoverflow
Solution 5 - MacosGnarkView Answer on Stackoverflow