[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Genrating a core at boot time



Am 21.11.2014 um 21:51 schrieb Erwan David:
> Following one of my bug report, the maintainer asks me to install the
> debug packages and try generating a core.
> But the crash happens only at boot time, the service can be started
> afterwards without problem.
> So I must reboot the server, while generating a core file that I can
> send afterwards.
> 
> The daemon is started by start-stop-daemon. Is it enough to add a
> cd /tmp
> ulimit -c 0
> in the /etc/init.d/ script, to get the core file in the /tmp directory ?

No on the ulimit, because 0 means disabled. You really want to use:

ulimit -c unlimited

Also no on the cd, because the daemon could chdir() to somewhere else.
(And most do btw.) What you rather want to do is set an appropriate
core_pattern to tell the kernel where tho store the core file.

Since this is only a temporary measure, you can probably do something like

echo "/tmp/core.%e.%p" > /proc/sys/kernel/core_pattern

in the init script. See http://linux.die.net/man/5/core for
documentation on this.

So basically, do:

ulimit -c unlimited
echo "/tmp/core.%e.%p" > /proc/sys/kernel/core_pattern

in the init script right before the start-stop-daemon. (Note also that
storing core files in /tmp is potentially unsafe, so please only do this
during debugging. You can reset the core_pattern to its default (also
during runtime of the server, no need to reboot) by just echoing the
string 'core' into that proc file (or whatever else you might want as a
pattern).

Note that core files can be quite large (depending on how much the
process allocated), so make sure the filesystem is large enough to
accommodate it.

Christian


Reply to: