[Bug 1069897] Re: gdb crashes on startup if run as root via sudo and ~/.gdbinit exists
James Hunt
1069897 at bugs.launchpad.net
Mon Nov 26 09:19:34 UTC 2012
I agree with Dave's comments in #3.
However, taking a closer look at gdb/cli/cli-cmds.c, I think further
changes need to be made to remove all possibility of a crash. The
behaviour of source_script_with_search() looks rather unusual in the
para-phrased snippet below (my comments prefixed by '/* XXX: '):
#-----------------------------------
old_cleanups = make_cleanup (xfree, full_path);
make_cleanup_fclose (stream);
if (stream == NULL)
{
/* XXX: since a cleanup was added for 'stream' before checking it opened correctly, this appears to *guarantee* a crash if it didn't */
}
if (from_tty == -1)
{
/* XXX: ? this is already been done above */
make_cleanup_fclose (stream);
}
#-----------------------------------
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gdb in Ubuntu.
https://bugs.launchpad.net/bugs/1069897
Title:
gdb crashes on startup if run as root via sudo and ~/.gdbinit exists
Status in “gdb” package in Ubuntu:
Triaged
Status in “gdb” package in Debian:
New
Bug description:
If a program is run like this:
$ sudo gdb ./a.out
and ~/.gdbinit exists (even as an empty file), gdb will crash...
$ cat crash_gdb.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int
main(int argc,
char *argv[])
{
printf ("hello\n");
exit (EXIT_SUCCESS);
}
$ gcc -g crash_gdb.c
$ ./a.out
hello
$ gdb ./a.out
GNU gdb (GDB) 7.5-ubuntu
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/a.out...done.
(gdb) r
Starting program: /tmp/a.out
hello
[Inferior 1 (process 11779) exited normally]
(gdb) quit
$ sudo gdb ./a.out
GNU gdb (GDB) 7.5-ubuntu
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/a.out...done.
(gdb) r
Starting program: /tmp/a.out
hello
[Inferior 1 (process 11839) exited normally]
(gdb) quit
$ ls ~/.gdbinit
ls: cannot access /home/james/.gdbinit: No such file or directory
$ touch ~/.gdbinit
$ sudo gdb ./a.out
GNU gdb (GDB) 7.5-ubuntu
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
warning: not using untrusted file "/home/james/.gdbinit"
*** glibc detected *** gdb: double free or corruption (!prev): 0x092e1cb8 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x75ee2)[0xb7217ee2]
/lib/i386-linux-gnu/libc.so.6(fclose+0x154)[0xb7207424]
gdb[0x82b2475]
gdb[0x816f576]
gdb(do_cleanups+0x19)[0x816f5d1]
gdb[0x80f43e4]
gdb(source_script+0x20)[0x80f4437]
gdb(catch_command_errors+0x42)[0x81d4a7f]
gdb[0x81d6fcb]
gdb(catch_errors+0x4c)[0x81d49a9]
gdb(gdb_main+0x34)[0x81d752a]
gdb(main+0x4f)[0x80880eb]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xb71bb4d3]
gdb[0x8087fd1]
======= Memory map: ========
/lib/i386-linux-gnu/libc.so.6(+0x75ee2)[0xb71fdee2]
/lib/i386-linux-gnu/libc.so.6(fclose+0x154)[0xb71ed424]
gdb[0x82b2475]
gdb[0x816f576]
gdb(do_cleanups+0x19)[0x816f5d1]
gdb[0x80f43e4]
gdb(source_script+0x20)[0x80f4437]
gdb(catch_command_errors+0x42)[0x81d4a7f]
gdb[0x81d6fcb]
gdb(catch_errors+0x4c)[0x81d49a9]
gdb(gdb_main+0x34)[0x81d752a]
gdb(main+0x4f)[0x80880eb]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xb71a14d3]
gdb[0x8087fd1]
======= Memory map: ========
08048000-0852b000 r-xp 00000000 08:01 5769330 /usr/bin/gdb
0852b000-0852c000 r--p 004e2000 08:01 5769330 /usr/bin/gdb
0852c000-08536000 rw-p 004e3000 08:01 5769330 /usr/bin/gdb
08536000-08551000 rw-p 00000000 00:00 0
092dd000-09401000 rw-p 00000000 00:00 0 [heap]
b6e9e000-b6f64000 rw-p 00000000 00:00 0
b6f64000-b7164000 r--p 00000000 08:01 5767792 /usr/lib/locale/locale-archive
b7164000-b7166000 rw-p 00000000 00:00 0
b7166000-b7182000 r-xp 00000000 08:01 6032119 /lib/i386-linux-gnu/libgcc_s.so.1
b7182000-b7183000 r--p 0001b000 08:01 6032119 /lib/i386-linux-gnu/libgcc_s.so.1
b7183000-b7184000 rw-p 0001c000 08:01 6032119 /lib/i386-linux-gnu/libgcc_s.so.1
b7184000-b7186000 r-xp 00000000 08:01 6029579 /lib/i386-linux-gnu/libutil-2.15.so
b7186000-b7187000 r--p 00001000 08:01 6029579 /lib/i386-linux-gnu/libutil-2.15.so
b7187000-b7188000 rw-p 00002000 08:01 6029579 /lib/i386-linux-gnu/libutil-2.15.so
b7188000-b732b000 r-xp 00000000 08:01 6029603 /lib/i386-linux-gnu/libc-2.15.so
b732b000-b732c000 ---p 001a3000 08:01 6029603 /lib/i386-linux-gnu/libc-2.15.so
b732c000-b732e000 r--p 001a3000 08:01 6029603 /lib/i386-linux-gnu/libc-2.15.so
b732e000-b732f000 rw-p 001a5000 08:01 6029603 /lib/i386-linux-gnu/libc-2.15.so
b732f000-b7332000 rw-p 00000000 00:00 0
b7332000-b7357000 r-xp 00000000 08:01 6031384 /lib/i386-linux-gnu/libexpat.so.1.6.0
b7357000-b7359000 r--p 00025000 08:01 6031384 /lib/i386-linux-gnu/libexpat.so.1.6.0
b7359000-b735a000 rw-p 00027000 08:01 6031384 /lib/i386-linux-gnu/libexpat.so.1.6.0
b735a000-b75c2000 r-xp 00000000 08:01 5770182 /usr/lib/libpython2.7.so.1.0
b75c2000-b75c3000 ---p 00268000 08:01 5770182 /usr/lib/libpython2.7.so.1.0
b75c3000-b75c4000 r--p 00268000 08:01 5770182 /usr/lib/libpython2.7.so.1.0
b75c4000-b761a000 rw-p 00269000 08:01 5770182 /usr/lib/libpython2.7.so.1.0
b761a000-b7627000 rw-p 00000000 00:00 0
b7627000-b763e000 r-xp 00000000 08:01 6031346 /lib/i386-linux-gnu/libpthread-2.15.so
b763e000-b763f000 r--p 00016000 08:01 6031346 /lib/i386-linux-gnu/libpthread-2.15.so
b763f000-b7640000 rw-p 00017000 08:01 6031346 /lib/i386-linux-gnu/libpthread-2.15.so
b7640000-b7642000 rw-p 00000000 00:00 0
b7642000-b766c000 r-xp 00000000 08:01 6031349 /lib/i386-linux-gnu/libm-2.15.so
b766c000-b766d000 r--p 00029000 08:01 6031349 /lib/i386-linux-gnu/libm-2.15.so
b766d000-b766e000 rw-p 0002a000 08:01 6031349 /lib/i386-linux-gnu/libm-2.15.so
b766e000-b7685000 r-xp 00000000 08:01 6029334 /lib/i386-linux-gnu/libz.so.1.2.7
b7685000-b7686000 r--p 00016000 08:01 6029334 /lib/i386-linux-gnu/libz.so.1.2.7
b7686000-b7687000 rw-p 00017000 08:01 6029334 /lib/i386-linux-gnu/libz.so.1.2.7
b7687000-b76a3000 r-xp 00000000 08:01 6031372 /lib/i386-linux-gnu/libtinfo.so.5.9
b76a3000-b76a5000 r--p 0001b000 08:01 6031372 /lib/i386-linux-gnu/libtinfo.so.5.9
b76a5000-b76a6000 rw-p 0001d000 08:01 6031372 /lib/i386-linux-gnu/libtinfo.so.5.9
b76a6000-b76c6000 r-xp 00000000 08:01 6031376 /lib/i386-linux-gnu/libncurses.so.5.9
b76c6000-b76c7000 r--p 0001f000 08:01 6031376 /lib/i386-linux-gnu/libncurses.so.5.9
b76c7000-b76c8000 rw-p 00020000 08:01 6031376 /lib/i386-linux-gnu/libncurses.so.5.9
b76c8000-b76c9000 rw-p 00000000 00:00 0
b76c9000-b76cc000 r-xp 00000000 08:01 6031354 /lib/i386-linux-gnu/libdl-2.15.so
b76cc000-b76cd000 r--p 00002000 08:01 6031354 /lib/i386-linux-gnu/libdl-2.15.so
b76cd000-b76ce000 rw-p 00003000 08:01 6031354 /lib/i386-linux-gnu/libdl-2.15.so
b76ce000-b7703000 r-xp 00000000 08:01 6089775 /lib/i386-linux-gnu/libreadline.so.6.2
b7703000-b7704000 r--p 00035000 08:01 6089775 /lib/i386-linux-gnu/libreadline.so.6.2
b7704000-b7707000 rw-p 00036000 08:01 6089775 /lib/i386-linux-gnu/libreadline.so.6.2
b7707000-b7708000 rw-p 00000000 00:00 0
b7728000-b772f000 r--s 00000000 08:01 5910153 /usr/lib/i386-linux-gnu/gconv/gconv-modules.cache
b772f000-b7730000 r--p 002bd000 08:01 5767792 /usr/lib/locale/locale-archive
b7730000-b7732000 rw-p 00000000 00:00 0
b7732000-b7752000 r-xp 00000000 08:01 6031350 /lib/i386-linux-gnu/ld-2.15.so
b7752000-b7753000 r--p 0001f000 08:01 6031350 /lib/i386-linux-gnu/ld-2.15.so
b7753000-b7754000 rw-p 00020000 08:01 6031350 /lib/i386-linux-gnu/ld-2.15.so
bfdeb000-bfe0c000 rw-p 00000000 00:00 0 [stack]
$ rm ~/.gdbinit
$ sudo gdb ./a.out
GNU gdb (GDB) 7.5-ubuntu
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/a.out...done.
(gdb) r
Starting program: /tmp/a.out
hello
[Inferior 1 (process 12057) exited normally]
(gdb) quit
$
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/1069897/+subscriptions
More information about the foundations-bugs
mailing list