[patch] bb_perror_nomsg_and_die() seg fault

Daniel Farrugia daniel at 2x.com
Tue May 29 10:05:45 UTC 2007


Hello List,

I am experiencing a seg fault when running the pivot_root applet linked
against uClibc. This seems to happen whenever pivot_root(2) fails (e.g.
by passing non-existing directories) and then bb_perror_nomsg_and_die()
is triggered:

# gdb --args ./busybox_unstripped pivot_root /foo /bar 
GNU gdb 6.3
...
(gdb) run
Starting program: /opt/busybox_unstripped pivot_root /foo /bar
pivot_root: 
Program received signal SIGSEGV, Segmentation fault.
0xb7ed0182 in vfprintf () from /lib/libc.so.0
(gdb) bt
#0  0xb7ed0182 in vfprintf () from /lib/libc.so.0
#1  0xb7ecfa66 in vfprintf () from /lib/libc.so.0
#2  0x080516cd in bb_verror_msg (s=0x0,
    p=0xbfaed4a4 "[rubbish]",
    strerr=0xb7ef3800 "No such file or directory") at libbb/verror_msg.c:26
#3  0x08051733 in bb_vperror_msg (s=0x0, 
    p=0xbfaed4a4 "[rubbish]") at libbb/vperror_msg.c:14
#4  0x08051257 in bb_perror_msg_and_die (s=0x0)
    at libbb/perror_msg_and_die.c:21
#5  0x08051263 in bb_perror_nomsg_and_die () at libbb/perror_nomsg_and_die.c:20
#6  0x0805d0f3 in pivot_root_main (argc=3, argv=0xbfaed5d8)
    at util-linux/pivot_root.c:23
#7  0x0804ae1d in run_applet_by_name (name=0xbfaef44f "pivot_root", argc=3, 
    argv=0xbfaed5d8) at applets/applets.c:493
#8  0x0804aeca in busybox_main (argc=4, argv=0xbfaed5d4)
    at applets/busybox.c:144
#9  0x0804ade0 in run_applet_by_name (name=0xbfaef43c "busybox_unstripped", 
    argc=4, argv=0xbfaed5d4) at applets/applets.c:484
#10 0x0804af20 in main (argc=4, argv=0xbfaed5d4) at applets/busybox.c:72

This problem doesn't happen when linking against glibc using the
standard toolchain that ships with debian sarge. I've tested with
busybox 1.5.1, buildroot-20070525 (uClibc 0.9.29, configured with
default settings) and the pre-compiled toolchain (uClibc 09.27)
available from uClibc's website.

The following trivial patch fixed this problem for me:

diff -urN a/libbb/perror_nomsg_and_die.c b/libbb/perror_nomsg_and_die.c
--- a/libbb/perror_nomsg_and_die.c  2007-05-20 18:56:18.000000000 +0200
+++ b/libbb/perror_nomsg_and_die.c  2007-05-29 11:11:54.000000000 +0200
@@ -17,5 +17,5 @@
 void bb_perror_nomsg_and_die(void);
 void bb_perror_nomsg_and_die(void)
 {
-       bb_perror_msg_and_die(0);
+       bb_perror_msg_and_die("");
 }

-- 
Daniel Farrugia




More information about the busybox mailing list