IBM Support

AIX Core Dump Facility

Question & Answer


Question

This document describes how to extend the default core dump facility on AIX with the chcore and syscorepath commands,

Answer


Introduction

The default core dump facility on AIX requires minimal configuration, and by default will create a binary file named core in the current working directory for the process that has terminated abnormally. If a core file is successfully created, a CORE_DUMP entry will also be written into the error report. The chcore and syscorepath commands can be used to provide additional functionality, and fix problems that can sometimes occur with the default core dump facility.

Note: See the technote How to Diagnose Core Dump Failure for more information about problems that can occur when using the default core dump facility.

Both chcore and syscorepath allow you to install a directory where all core files will be written. The chcore command also allows you to enable core file compression, and unique core file naming, so that each core file written into the directory will have a unique file name. Both commands (if the chcore -n on option is used) will create unique core file names with the format core.pid.ddhhmmss, where pid is the process ID, dd is the day of the month, hh is the hour in 24-hour format, mm is minutes, and ss is seconds. For security reasons, the default core dump facility will not write a core file for an executable that has the suid or sgid permissions set, but syscorepath will allow core dumps from these types of binaries to be created. In general you should use the newer chcore command to extend the functionality of the default core dump facility, and use syscorepath only if you need the suid/sgid feature not available with chcore.

Core File Settings

There are only a few configurable core file settings. The most important of these is the fullcore setting. If enabled, fullcore will increase the size of each core file written on the system by including additional information such as shared memory segments that might be needed in order to find the cause of a problem, and additional data needed when debugging multi-threaded programs.
  • To enable full core:
    chdev -l sys0 -a fullcore=true
  • To disable full core:
    chdev -l sys0 -a fullcore=false
  • To check the current setting for full core:
    lsattr -l sys0 -a fullcore -E
  • To disable core file creation:
    ulimit -c 0

    Note: Core file creation in a particular user account can be disabled if the core ulimit is set to 0. A core ulimit greater than 0 determines the maximum size of the core file in bytes. System ulimits are set and viewed with the ulimit command, and in /etc/security/limits.

chcore and lscore Commands

The chcore command can be used to configure directories as core dump repositories, and the lscore command displays the current core file settings. Unlike the default core file facility, chcore allows you to have complete control over where core dump files will be written. With chcore you can set up a default directory that can be used as a core file repository for all accounts on the system, including root. However each user, again including root, can override the default directory and install a directory in their home directory as a core file repository for core files generated from processes owned by that account.

A central core file repository can be set up for all accounts on the system, but each account may override the default and install a custom repository. Select a file system with plenty of free space for this repository. All accounts will need read and write access to this directory. To prevent users from deleting core files created by other users, the sticky bit should be enabled. Permissions on this directory should normally be 1777, the same as for /tmp.
  • To set up a system-wide core file repository with unique core file naming, run the following commands as root:
    cd /path/to/filesystem
    mkdir corefiles
    chmod 1777 ./corefiles
    chcore -p on -n on -l ./corefiles


    Note: Add the option -c on to turn on core file compression. The settings will only be effective for newly logged in accounts and will persist across reboots.
  • To override the system-wide default repository and set up a repository for a specific user, run the following commands as the user:
    mkdir ~/corefiles
    chcore -p on -n on -l ~/corefiles
  • To list the system-wide default core file settings:
    lscore -d
  • To list the core file settings for a specific user:
    lscore user

syscorepath Command

The syscorepath command is less capable than chcore but has the ability to allow creation of core files for suid and sgid programs. This command will only configure a system-wide repository for core files; it does not have the capability to configure user specific repositories. Settings made with this command do not persist across reboots. This command can only be executed by root.
  • To set up a system-wide core file repository with unique core file naming:
    cd /path/to/filesystem
    mkdir corefiles
    chmod 1777 ./corefiles
    syscorepath -p ./corefiles
  • To display the current respository:
    syscorepath -g
  • To unset the directory used as the repository and revert back to the default behavior of writing core files in the current working directory for the process:
    syscorepath -c

Man Pages (AIX 7.1)

core file format
chcore
lscore
syscorepath

Conclusion

The default core dump facility on AIX is very basic, and can occasionally cause problems when creating core files. The chcore and syscorepath commands can be used to gain more control over how and where core files are written to avoid these problems. The newer chcore command is preferred over the less capable syscorepath command, but syscorepath allows the creation of core dumps for suid and sgid executablesh, and may be used together with chcore.

[{"Type":"MASTER","Line of Business":{"code":"LOB08","label":"Cognitive Systems"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG10","label":"AIX"},"ARM Category":[{"code":"a8m0z0000001fMuAAI","label":"AIX General Support"}],"ARM Case Number":"","Platform":[{"code":"PF002","label":"AIX"}],"Version":"All Versions"}]

Document Information

Modified date:
09 November 2021

UID

isg3T1019236