sysctl segfaulting

Michael Nottebrock lofi at freebsd.org
Sat Feb 17 11:51:52 UTC 2007


On Saturday, 17. February 2007 11:39, Rink Springer wrote:
> Hi Michael,
>
> On Sat, Feb 17, 2007 at 11:36:46AM +0100, Michael Nottebrock wrote:
> > So I tried recompiling libc with debug cflags ("-g3 -O -pipe"), but this
> > only makes the backtrace in gdb much longer, but still without any
> > function names.
>
> Hmm, 'make install' appears to strip the debugging info.

Duh, I keep forgetting that.

> Please try 
> gdb-ing /usr/obj/usr/src/sbin/sysctl/sysctl instead (assuming you use
> default the /usr/obj path like I do)

I recompiled/reinstalled both sysctl and libc with CFLAGS=-g3 and STRIP="" and 
now I get:

[lofi at lofi]:0:~ > gdb /sbin/sysctl
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
(gdb) set args kern.clockrate
(gdb) run
Starting program: /sbin/sysctl kern.clockrate
kern.clockrate:
Program received signal SIGSEGV, Segmentation fault.
0x08049696 in S_clockinfo (l2=20, p=0x804e000) 
at /usr/src/sbin/sysctl/sysctl.c:333
333             printf(hflag ? "{ hz = %'d, tick = %'d, profhz = %'d, stathz 
= %'d }" :
(gdb) bt
#0  0x08049696 in S_clockinfo (l2=20, p=0x804e000)
    at /usr/src/sbin/sysctl/sysctl.c:333
#1  0x0804a5f2 in show_var (oid=0xbfbfea80, nlen=2)
    at /usr/src/sbin/sysctl/sysctl.c:690
#2  0x08049093 in parse (string=0xbfbfecb1 "kern.clockrate")
    at /usr/src/sbin/sysctl/sysctl.c:208
#3  0x08048e77 in main (argc=0, argv=0xbfbfeba0) 
at /usr/src/sbin/sysctl/sysctl.c:152
(gdb) list
328             struct clockinfo *ci = (struct clockinfo*)p;
329             if (l2 != sizeof(*ci)) {
330                     warnx("S_clockinfo %d != %d", l2, sizeof(*ci));
331                     return (0);
332             }
333             printf(hflag ? "{ hz = %'d, tick = %'d, profhz = %'d, stathz 
= %'d }" :
334                     "{ hz = %d, tick = %d, profhz = %d, stathz = %d }",
335                     ci->hz, ci->tick, ci->profhz, ci->stathz);
336             return (0);
337     }
(gdb) print ci->hz
Error accessing memory address 0x804e000: Bad address.
(gdb) print ci->tick
Error accessing memory address 0x804e004: Bad address.
(gdb) print ci->profhz
Error accessing memory address 0x804e010: Bad address.
(gdb) print ci->stathz
Error accessing memory address 0x804e00c: Bad address.
(gdb) print ci
$1 = (struct clockinfo *) 0x804e000
(gdb) print p
$2 = (void *) 0x804e000
(gdb) print l2
$3 = 20

-- 
   ,_,   | Michael Nottebrock               | lofi at freebsd.org
 (/^ ^\) | FreeBSD - The Power to Serve     | http://www.freebsd.org
   \u/   | K Desktop Environment on FreeBSD | http://freebsd.kde.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20070217/38a2ca0f/attachment.pgp


More information about the freebsd-stable mailing list