interesting segfault when running awk as pid==1

Laurent Bercot ska-dietlibc at skarnet.org
Fri Jul 6 11:03:38 UTC 2012


> As I stated in my initial email, when running awk from a subshell
> it works.  I know PID=1 is special, and for one, it can't be straced
> or debugged.

 Actually, on some Linux versions (I'm not certain which ones though,
but it should work on modern kernels), process 1 *can* be straced:
somehow get a shell running and do "strace -p 1". If you're not afraid
of dirty hacks, you could even run that from your /init, if everything
is properly mounted:
 ( strace -p 1 </dev/null >/dev/null 2>/tmp/strace-file ) &
or even replace /tmp/strace-file with /dev/tty for a live performance.


> And finally, it isn't a solution to run it from a subshell,
> since running awk from within /init in initramfs is a valid usage
> case.

 But are you really running awk as process 1 ?
 I doubt your /init script is *executing* awk. If it was, then after
performing its work, awk would die, and your kernel would panic.
I suspect that instead, your /init script looks like

#!/bin/sh
...
awk something
...
exec chroot foobar /sbin/init

 in which case you are *not* running awk as process 1: your shell is
forking first, then executing awk as a child. The question then becomes,
why is there a problem when awk is run directly as process 1's child.

-- 
 Laurent


More information about the busybox mailing list