[vox-tech] glibc and socket()

Jeff Newmiller vox-tech@lists.lugod.org
Mon, 10 Feb 2003 21:11:24 -0800 (PST)


On Mon, 10 Feb 2003, Nicole the Wonder Nerd wrote:

> Hi guys
> 
> I'm trying to track down a kernel bug.  I've compiled my programs and the kernel 
> with -g, and I'm stepping through the executable with gdb.

I haven't tried to debug the kernel, but some ideas percolate up...

a) make sure your glibc and userspace applications are compiled against
the same kernel headers, and that those kernel headers are of equal or
older vintage as the kernel you are using.  See Linus' rant [1] on kernel
headers if you haven't already...

> A call to sockaddr_check() goes through OK, but a subsequent call to socket() 
> triggers a kernel panic.  Control never even gets to the first line of socket().

You know this without recompiling glibc for debugging?  Or are you saying
it doesn't get to sys_socket()?  The latter sounds an awful lot like
header problems.

I am pretty sure it is possible to debug with gdb into glibc without
recompiling glibc if you are willing to single step in machine code.  If
you have the glibc source to look at and have a vague understanding of how
C code looks in assembly, this shouldn't be too challenging.  You will
want to look for the software interrupt that invokes the user-to-kernel
context switch... if you make it to that instruction, and the headers are
compatible (big question mark), then the problem is in the kernel.

[1] http://uwsg.iu.edu/hypermail/linux/kernel/0007.3/0587.html

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil@dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...2k
---------------------------------------------------------------------------