This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/13619] New: Crash when running binary a second time in thesame session


http://sourceware.org/bugzilla/show_bug.cgi?id=13619

             Bug #: 13619
           Summary: Crash when running binary a second time in the same
                    session
           Product: gdb
           Version: 7.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
        AssignedTo: unassigned@sourceware.org
        ReportedBy: hyrum@hyrumwright.org
    Classification: Unclassified


Platform:  OS X 10.7
GCC Version: 4.2.1

I downloaded and build gdb 7.4 this afternoon, and in doing so discovered that
repeatedly running a binary in the same gdb session results in a segfault, as
shown below.  The first invocation succeeded, but upon attempting to run the
binary resulted in the crash.

[[[
$ uname -a
Darwin foo.local 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug  9 20:54:00 PDT
2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64
$ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658)
(LLVM build 2336.1.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cat test.c
#include <stdio.h>

int main(int argc, char *argv[])
{
  printf("Hello, World!\n");
  return 0;
}
$ gcc -g test.c
$ /usr/local/bin/gdb ./a.out
GNU gdb (GDB) 7.4
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 "x86_64-apple-darwin11.2.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /Users/Hyrum/dev/test/a.out...Reading symbols from
/Users/Hyrum/dev/test/a.out.dSYM/Contents/Resources/DWARF/a.out...done.
done.
(gdb) r
Starting program: /Users/Hyrum/dev/test/a.out 
Hello, World!
[Inferior 1 (process 5654) exited normally]
(gdb) r
gdb(5653) malloc: *** error for object 0x107bc5b40: pointer being freed was not
allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
$ 
]]]

Debugging my custom build gdb with my stock gdb gives the following:

[[[
$ gdb /usr/local/bin/gdb
GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Thu Nov  3 21:59:02 UTC 2011)
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 "x86_64-apple-darwin"...Reading symbols for shared
libraries ......
warning: Could not find object file
"/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/python26/work/Python-2.6.7/libpython2.6.a(getbuildinfo.o)"
- no debug information available for "./Modules/getbuildinfo.c".

[ above message repeated a number of times for different object files ]

.. done

(gdb) b malloc_error_break
Function "malloc_error_break" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (malloc_error_break) pending.
(gdb) r ./a.out
Starting program: /usr/local/bin/gdb ./a.out
Reading symbols for shared libraries +++++++...............................
done
Breakpoint 1 at 0x7fff8d32c6c0
Pending breakpoint 1 - "malloc_error_break" resolved
GNU gdb (GDB) 7.4
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 "x86_64-apple-darwin11.2.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /Users/Hyrum/dev/test/a.out...Reading symbols from
/Users/Hyrum/dev/test/a.out.dSYM/Contents/Resources/DWARF/a.out...done.
done.
(gdb) r
Starting program: /Users/Hyrum/dev/test/a.out 
Hello, World!
[Inferior 1 (process 5672) exited normally]
(gdb) r
gdb(5670) malloc: *** error for object 0x1002c3b40: pointer being freed was not
allocated
*** set a breakpoint in malloc_error_break to debug

Breakpoint 1, 0x00007fff8d32c6c0 in malloc_error_break ()
(gdb) bt
#0  0x00007fff8d32c6c0 in malloc_error_break ()
#1  0x00007fff8d32c805 in free ()
#2  0x000000010013e34c in free_objfile (objfile=0x10124ca00) at objfiles.c:597
#3  0x000000010013e547 in objfile_purge_solibs () at objfiles.c:986
#4  0x000000010012d09e in target_pre_inferior (from_tty=3) at target.c:2479
#5  0x00000001000f2f3c in run_command_1 (args=0x0, from_tty=1,
tbreak_at_main=0) at infcmd.c:516
#6  0x00000001001c2d79 in execute_command (p=0x10080a201 "", from_tty=1) at
top.c:441
#7  0x000000010011267d in command_handler (command=0x10080a200 "") at
event-top.c:435
#8  0x00000001001122be in command_line_handler (rl=0x10086ba50 "r") at
event-top.c:642
#9  0x00000001002014db in rl_callback_read_char () at callback.c:220
#10 0x0000000100111e69 in rl_callback_read_char_wrapper
(client_data=0x10080a201) at event-top.c:169
#11 0x0000000100110e8e in process_event () at event-loop.c:401
#12 0x0000000100110d01 in gdb_do_one_event () at event-loop.c:465
#13 0x0000000100111da5 in start_event_loop () at event-loop.c:490
#14 0x000000010010cb66 in captured_command_loop (data=0x10080a201) at
main.c:232
#15 0x000000010010a896 in catch_errors (func=0x10010cb50
<captured_command_loop>, func_args=0x0, errstring=0x7fff5fbff920 "", mask=6) at
exceptions.c:502
#16 0x000000010010c8f2 in captured_main (data=0x7fff5fbffa00) at main.c:942
#17 0x000000010010a896 in catch_errors (func=0x10010ba00 <captured_main>,
func_args=0x7fff5fbffa80, errstring=0x7fff5fbffa60 "p??_?", mask=6) at
exceptions.c:502
#18 0x000000010010b9eb in gdb_main (args=0x3) at main.c:951
#19 0x00000001000016b6 in main (argc=1606417419, argv=0x3) at gdb.c:34
(gdb) quit
The program is running.  Exit anyway? (y or n) y
$ 
]]]

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]