[systemd-devel] Systemd / PID 1 leak
Lennart Poettering
lennart at poettering.net
Wed Nov 20 13:26:48 PST 2013
On Tue, 19.11.13 22:28, Colin Guthrie (gmane at colin.guthr.ie) wrote:
>
> 'Twas brillig, and Oleksii Shevchuk at 19/11/13 21:10 did gyre and gimble:
> >> Valgrind
> >
> > Any methodology for pid 1 valgrinding? How to start/gather information
> > for example?
> >
> > Do you have any setup for that? Maybe I can clone it
>
> Probably best to use systemd-nspawn and a container tree to "boot" a
> virtual PID 1.
>
> I don't know the correct commands to run but I think this is typically
> the best approach.
Hmm, so I must admit I never tried running systemd as PID 1 in a
valgrind so far (only --user mode, and that daily). Turns out however,
that it actually works... Well, at least after I added this patch to systemd:
http://cgit.freedesktop.org/systemd/systemd/commit/?id=54b434b1b5055f934230fe04fad35b01642b8488
That patch is needed since PID 1 execs the shutdown binary as last step
of shutdown which then will do the actual shutdown. However, valgrind
won't print any final summary then (it does so only if the original
process exit()s, not when it exec()s) which would make it quite
useless. Hence, in order to trigger the summary output this patch will
explicitly exit() from PID 1 rather than do the real shutdown if
valgrind is detected.
I tested this in a container:
systemd-nspawn -D /home/lennart/fedora-tree /usr/bin/valgrind --log-file=/log /usr/lib/systemd/system
Of course, make sure to compile a version of systemd with that patch
applied in the container first, and make sure to install valgrind-devel
before that.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list