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/20948] --write option to GDB causes segmentation fault


https://sourceware.org/bugzilla/show_bug.cgi?id=20948

Stefan Markovic <stefan.markovic@rt-rk.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stefan.markovic@rt-rk.com

--- Comment #11 from Stefan Markovic <stefan.markovic@rt-rk.com> ---
Hi Jozef,

(In reply to Jozef Lawrynowicz from comment #8)
> My revised patch which fixes the core BFD issue is here:
> https://sourceware.org/ml/binutils/2018-03/msg00228.html

When I apply this patch (to freshly cloned GDB master branch - latest commit is
from Aug 29th), I still have some issues. Here's the detailed report:

$cat test.c
int main(int argc, char const *argv[])
{
        /* code */
        return 0;
}

$gcc -g test.c

$./buildGDB/gdb/gdb -write a.out

GNU gdb (GDB) 8.2.50.20180829-git
Copyright (C) 2018 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-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...done.
(gdb) q

Here, gdb exits normally. BUT, when I pass same a.out file to gdb again(with or
without -write option)  I get:

Reading symbols from a.out...BFD: a.out: invalid string offset 1953392942 >=
548 for section `.strtab'
BFD: a.out: invalid string offset 778400879 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 771778675 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 1936876918 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 1634493810 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 1702112768 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 1634887263 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 1633645673 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 1680736370 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 1633955328 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 1600615778 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 1650811950 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 1680736357 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 4194872 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 596 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 4194968 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 696 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 4195128 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 832 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 4195192 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 936 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 4195328 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 1396 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 4195716 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 1464 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 6295064 >= 548 for section `.strtab'
BFD: a.out: invalid string offset 3616 >= 548 for section `.strtab'
done.

Also, if I pass .o file to gdb with built with Your patch applied, I still get
segmentation fault and few assertions fails:

$gcc -g test.c -c

$./buildGDB/gdb/gdb -write -quiet test.o
Reading symbols from test.o...done.
(gdb) q
BFD: BFD (GNU Binutils) 2.31.51.20180829 assertion fail ../../bfd/elf.c:5766
BFD: BFD (GNU Binutils) 2.31.51.20180829 assertion fail ../../bfd/elf.c:5766
BFD: BFD (GNU Binutils) 2.31.51.20180829 assertion fail ../../bfd/elf.c:5766
BFD: BFD (GNU Binutils) 2.31.51.20180829 assertion fail ../../bfd/elf.c:5766
BFD: BFD (GNU Binutils) 2.31.51.20180829 assertion fail
../../bfd/elf-strtab.c:280
Segmentation fault (core dumped)

$gdb buildGDB/gdb/gdb
(gdb) set prompt (TOP_GDB) 
(TOP_GDB) run -write test.o
(gdb) q
BFD: BFD (GNU Binutils) 2.31.51.20180829 assertion fail ../../bfd/elf.c:5766
BFD: BFD (GNU Binutils) 2.31.51.20180829 assertion fail ../../bfd/elf.c:5766
BFD: BFD (GNU Binutils) 2.31.51.20180829 assertion fail ../../bfd/elf.c:5766
BFD: BFD (GNU Binutils) 2.31.51.20180829 assertion fail ../../bfd/elf.c:5766
BFD: BFD (GNU Binutils) 2.31.51.20180829 assertion fail
../../bfd/elf-strtab.c:280

Program received signal SIGSEGV, Segmentation fault.
_bfd_elf_strtab_offset (tab=0xfcede0, idx=44) at ../../bfd/elf-strtab.c:283
283       BFD_ASSERT (entry->refcount > 0);
(TOP GDB) p entry->refcount 
Cannot access memory at address 0x6924000064726f93

-- 
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]