[uClibc]malloc problem?
Joseph Chiu
josephc at idealab.com
Wed Jul 31 17:43:58 MDT 2002
Ah-ha! Rather than to debug the problem under my very limited MIPS
environment, I was able to duplicate the problem on Intel, fired up gdb, and
found the problem.
Here's the patch for initgroups.c that was causing su to die (basically an
off-by-one error) by writing junk onto malloc's pointers.
===================================================================
RCS file: /var/cvs/uClibc/libc/pwd_grp/initgroups.c,v
retrieving revision 1.4
diff -r1.4 initgroups.c
66c66
< group_list[num_groups] = group->gr_gid;
---
> group_list[num_groups-1] = group->gr_gid;
Moral of the story: sometimes, the bug is not architecture-dependent.
Joseph
-----Original Message-----
From: uclibc-admin at uclibc.org [mailto:uclibc-admin at uclibc.org]On Behalf
Of Erik Andersen
Sent: Saturday, July 27, 2002 12:36 AM
To: Joseph Chiu
Cc: Uclibc at Uclibc. Org
Subject: Re: [uClibc]malloc problem?
On Fri Jul 26, 2002 at 10:49:46PM -0700, Joseph Chiu wrote:
> Ive been trying to track down a tinylogin su problem that started after I
> grabbed the latest CVS two days ago (prior to that my uclibc was about 6
> weeks old). I traced the problem and found that su would segfault inside
> malloc() (malloc-930716/malloc.c).
>
> The segfault would not happen in the MALLOC=malloc version of malloc. I
> tried back-reving malloc to a many-months old version of the
> MALLOC=malloc-930716, but I still get a segfault in malloc.
Wierd stuff indeed...
> Im on linux 2.4.18-mips, BTW.
>
> (BTW, does gdb work with uclibc? Last time I tried to build gdb on my
> platform it was a mess, and I havent tried since.)
gdb works great to debug uClibc based app. I use it _all_ the
time when trying to track down wierd uClibc bugs....
It also works great even when gdb is itself linked vs uClibc. I
agree -- a month or two ago gdb linked vs uClibc was indeed a
terrible mess but things have gotten significantly better of late
and it works just great. I have a script to build gdb vs uClibc
(and to build ncurses which it needs) under buildroot in CVS.
~/busybox # ldd /usr/bin/gdb
libncurses.so.5 => /lib/libncurses.so.5
libm.so.0 => /lib/libm.so.0
libdl.so.0 => /lib/libdl.so.0
libc.so.0 => /lib/libc.so.0
/lib/ld-uClibc.so.0 => /lib/ld-uClibc.so.0
~/busybox # gdb ./busybox
GNU gdb 5.2
Copyright 2002 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 "i686-pc-linux-gnu"...
(gdb) set args echo "hello world"
(gdb) b echo_main
Breakpoint 1 at 0x8060c2e: file echo.c, line 33.
(gdb) r
Starting program: /root/busybox/busybox echo "hello world"
Breakpoint 1, echo_main (argc=2, argv=0x9ffffe44) at echo.c:33
33 int nflag = 0;
(gdb) n
34 int eflag = 0;
(gdb) n
37 argc--;
[-------etc, etc, etc---------]
-Erik
--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--
_______________________________________________
uClibc mailing list
uClibc at uclibc.org
http://uclibc.org/mailman/listinfo/uclibc
More information about the uClibc
mailing list