[CentOS] another bizarre thing...

Warren Young
Tue, 06 Aug 2019 11:27:54 -0000

On Aug 5, 2019, at 6:57 PM, Fred Smith <fredex at fcshome.stoneham.ma.us>
wrote:
>
> no core file (yes, ulimit is configured)

That?s nowhere near sufficient.  To restore classic core file dumps on CentOS 7,
you must:

1. Remove Red Hat?s ABRT system, which wants to catch all of this and handle it
directly.  Say something like ?sudo yum remove abrt*?


2. Override the default sysctl telling where core dumps land by writing this
file, /etc/sysctl.d/10-core.conf:

    kernel.core_pattern = /tmp/core-%e-%p
    kernel.core_uses_pid = 1
    fs.suid_dumpable = 2

Then apply those settings with ?sudo sysctl ?system?.

I don?t remember what the default is, which this overrides, but I definitely
didn?t want it.

You can choose any pattern you like, just remember what permissions the service
runs under, because that?s the permission needed by the process that actually
dumps the core to make the file hit the disk.  That?s why I chose /tmp in this
example: anyone can write there.


3. Raise the limits by writing the following to
/etc/security/limits.d/10-core.conf:

    * hard core unlimited
    * soft core unlimited

If this is what you meant by ?ulimit,? then great, but I suspect you actually
meant ?ulimit -c unlimited?, but I believe until you do the above, the ulimit
CLI app can have no effect.  You have to log out and back in to make this take
effect.

Once the above is done, ?ulimit -c unlimited? can take effect, but it?s of no
value at all in conjunction with systemd services, for example, since those
don?t run under a standard shell, so your .bash_profile and such aren?t even
exec?d.


4. If your program is launched via systemd, then you must edit
/etc/systemd/system.conf and set

    DefaultLimitCORE=infinity

then say ?sudo systemctl daemon-reeexec?

Case matters; ?Core? won?t work.  Ask me how I know. :)


5. If you have a systemd unit file for your service, you have to set a related
value in there as well:

    LimitCore=infinity

You need both because #4 sets the system-wide cap, while this sets the
per-service value, which can go no higher than the system cap.


6. Restart the service to apply the above two changes.


Yes, it really is that difficult to enable classic core dumps on CentOS 7.
You?re welcome. :)