Package: gdb
Version: 7.11.1-2
Severity: normal

Dear Maintainer,

When I use "gdb --write" on a trivial executable and immediately type
"quit", GDB segfaults:

wraith:/tmp/hello$ cat > hello.c
#include <stdio.h>

int main(int argc, char **argv)
{

        printf("hello, world\n");
        return 0;
}
wraith:/tmp/hello$ gcc -o hello hello.c
wraith:/tmp/hello$ gdb --quiet --write hello
Reading symbols from hello...(no debugging symbols found)...done.
(gdb) quit
Segmentation fault
wraith:/tmp/hello$

With gdb-dbg installed and running gdb under gdb, I get this stack
backtrace when doing the same thing:

#0  _bfd_elf_strtab_finalize (tab=0x0)
    at /build/gdb-NKZwtf/gdb-7.11.1/bfd/elf-strtab.c:342
#1 0x08321a7b in _bfd_elf_assign_file_positions_for_non_load (abfd=0x8755528)
    at /build/gdb-NKZwtf/gdb-7.11.1/bfd/elf.c:5840
#2  _bfd_elf_write_object_contents (abfd=0x8755528)
    at /build/gdb-NKZwtf/gdb-7.11.1/bfd/elf.c:5876
#3  0x08306a92 in bfd_close (abfd=0x8755528)
    at /build/gdb-NKZwtf/gdb-7.11.1/bfd/opncls.c:733
#4  0x082062d7 in gdb_bfd_close_or_warn (abfd=0x8755528)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/gdb_bfd.c:490
#5  gdb_bfd_unref (abfd=0x8755528)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/gdb_bfd.c:618
#6 0x08224275 in exec_close () at /build/gdb-NKZwtf/gdb-7.11.1/gdb/exec.c:94
#7  0x082249a3 in exec_close_1 (self=0x86465e0 <exec_ops>)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/exec.c:122
#8  0x0821ad22 in target_close (targ=0x86465e0 <exec_ops>)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/target.c:3318
#9  0x0821aee8 in unpush_target (t=0x86465e0 <exec_ops>)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/target.c:752
#10 0x0821af2c in unpush_target_and_assert (target=0x86465e0 <exec_ops>)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/target.c:762
#11 0x0821afba in pop_all_targets_above (above_stratum=dummy_stratum)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/target.c:776
#12 pop_all_targets () at /build/gdb-NKZwtf/gdb-7.11.1/gdb/target.c:791
#13 0x082b4276 in quit_force (args=0x0, from_tty=1)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/top.c:1578
#14 0x082b31c7 in execute_command (p=<optimized out>, from_tty=1)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/top.c:475
#15 0x081ed993 in command_handler (command=0x8661cb8 "quit")
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/event-top.c:491
#16 0x081ede52 in command_line_handler (rl=0x87c9008 "")
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/event-top.c:696
#17 0xb7f8deb2 in rl_callback_read_char ()
   from /lib/i386-linux-gnu/libreadline.so.6
#18 0x081ed9f8 in rl_callback_read_char_wrapper (client_data=0x0)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/event-top.c:171
#19 0x081eda44 in stdin_event_handler (error=0, client_data=0x0)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/event-top.c:430
#20 0x081ec1b6 in handle_file_event (file_ptr=0x8798798,
    ready_mask=<optimized out>)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/event-loop.c:708
#21 0x081ec885 in gdb_wait_for_event (block=block@entry=1)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/event-loop.c:834
#22 0x081eca1b in gdb_do_one_event ()
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/event-loop.c:323
#23 0x081ecb4e in start_event_loop ()
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/event-loop.c:347
#24 0x081e60c8 in current_interp_command_loop ()
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/interps.c:317
#25 0x081e6b32 in captured_command_loop (data=0x0)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/main.c:318
#26 0x081e38d6 in catch_errors (func=0x81e6b20 <captured_command_loop>,
    func_args=0x0, errstring=0x839d2a5 "", mask=RETURN_MASK_ALL)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/exceptions.c:240
#27 0x081e7713 in captured_main (data=0xbffff6e0)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/main.c:1157
#28 0x081e38d6 in catch_errors (func=0x81e7080 <captured_main>,
    func_args=0xbffff6e0, errstring=0x839d2a5 "", mask=RETURN_MASK_ALL)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/exceptions.c:240
#29 0x081e7fc8 in gdb_main (args=0xbffff6e0)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/main.c:1165
#30 0x08095e77 in main (argc=3, argv=0xbffff7a4)
    at /build/gdb-NKZwtf/gdb-7.11.1/gdb/gdb.c:32

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 4.6.0-1-686-pae (SMP w/8 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash
Init: systemd (via /run/systemd/system)

Versions of packages gdb depends on:
ii  libbabeltrace-ctf1  1.4.0-3
ii  libbabeltrace1      1.4.0-3
ii  libc6               2.23-4
ii  libexpat1           2.2.0-1
ii  liblzma5            5.1.1alpha+20120614-2.1
ii  libncurses5         6.0+20160625-1
ii  libpython3.5        3.5.2-3
ii  libreadline6        6.3-8+b4
ii  libtinfo5           6.0+20160625-1
ii  zlib1g              1:1.2.8.dfsg-2+b1

Versions of packages gdb recommends:
ii  gdbserver             7.11.1-2
ii  libc6-dbg [libc-dbg]  2.23-4

Versions of packages gdb suggests:
pn  gdb-doc  <none>

-- no debconf information

--
Ben Harris, University of Cambridge Information Services.

Reply via email to