Bug 1540559 - gdb: Out-of-bounds vector access while running gdb-add-index
Summary: gdb: Out-of-bounds vector access while running gdb-add-index
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: gdb
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Jan Kratochvil
QA Contact: Fedora Extras Quality Assurance
URL: https://sourceware.org/ml/gdb-patches...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-01-31 12:04 UTC by Florian Weimer
Modified: 2018-02-05 07:51 UTC (History)
4 users (show)

Fixed In Version: gdb-8.1-5.fc28
Clone Of:
Environment:
Last Closed: 2018-02-05 07:51:53 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
libcurl.so (4.15 MB, application/octet-stream)
2018-01-31 12:04 UTC, Florian Weimer
no flags Details

Description Florian Weimer 2018-01-31 12:04:10 UTC
Created attachment 1388922 [details]
libcurl.so

Running

  gdb-add-index libcurl.so

on the attached file results in:

/usr/include/c++/7/bits/stl_vector.h:797: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = partial_symbol*; _Alloc = std::allocator<partial_symbol*>; std::vector<_Tp, _Alloc>::reference = partial_symbol*&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]: Assertion '__builtin_expect(__n < this->size(), true)' failed.
/usr/bin/gdb-add-index: line 61: 15720 Aborted                 (core dumped) $GDB --batch -nx -iex 'set auto-load no' -ex "file $file" -ex "save gdb-index $dir"
gdb-add-index: gdb error generating index for ./lib/.libs/libcurl.so

This happens with gdb-headless-8.0.90.20180109-2.fc28.x86_64.

The assertion was recently enabled in rawhide (via a redhat-rpm-config change).  Absence of the crash in earlier versions does not mean that the bug isn't there.

Backtrace:

(gdb) bt
#0  0x00007ffff48ddf6b in raise () from /lib64/libc.so.6
#1  0x00007ffff48c8591 in abort () from /lib64/libc.so.6
#2  0x0000555555689e04 in std::__replacement_assert (__file=__file@entry=0x555555b539d8 "/usr/include/c++/7/bits/stl_vector.h", 
    __line=__line@entry=797, 
    __function=__function@entry=0x555555bdce40 <std::vector<partial_symbol*, std::allocator<partial_symbol*> >::operator[](unsigned long)::__PRETTY_FUNCTION__> "std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = partial_symbol*; _Alloc = std::allocator<partial_symbol*>; std::vector<_Tp, _A"..., 
    __condition=__condition@entry=0x555555b539a8 "__builtin_expect(__n < this->size(), true)")
    at /usr/include/c++/7/x86_64-redhat-linux/bits/c++config.h:2433
#3  0x0000555555883a7f in std::vector<partial_symbol*, std::allocator<partial_symbol*> >::operator[] (__n=<optimized out>, 
    this=0x555556a40928) at /usr/include/c++/7/bits/stl_vector.h:797
#4  recursively_write_psymbols (objfile=objfile@entry=0x555556a40850, psymtab=psymtab@entry=0x555556af7b80, 
    symtab=symtab@entry=0x7fffffffde10, psyms_seen=std::unordered_set with 3422 elements = {...}, cu_index=cu_index@entry=121)
    at ../../gdb/dwarf2read.c:26190
#5  0x0000555555888de4 in write_gdbindex (out_file=0x555556a40550, objfile=0x555556a40850, this=<optimized out>, 
    this=<optimized out>) at ../../gdb/dwarf2read.c:26870
#6  write_psymtabs_to_index (index_kind=dw_index_kind::GDB_INDEX, dir=0x7fffffffe80b "./lib/.libs", objfile=0x555556a40850, 
    this=<optimized out>, this=<optimized out>, this=<optimized out>, this=<optimized out>, this=<optimized out>, 
    this=<optimized out>, this=<optimized out>, this=<optimized out>) at ../../gdb/dwarf2read.c:27139
#7  save_gdb_index_command (arg=0x7fffffffe80b "./lib/.libs", from_tty=<optimized out>) at ../../gdb/dwarf2read.c:27190
#8  0x0000555555735122 in cmd_func (cmd=<optimized out>, args=<optimized out>, from_tty=<optimized out>)
    at ../../gdb/cli/cli-decode.c:1886
#9  0x00005555559b1dea in execute_command (p=<optimized out>, p@entry=0x7fffffffe7fc "save gdb-index ./lib/.libs", 
    from_tty=from_tty@entry=0) at ../../gdb/top.c:630
#10 0x00005555558fc968 in catch_command_errors (command=0x5555559b18d0 <execute_command(char const*, int)>, 
    arg=0x7fffffffe7fc "save gdb-index ./lib/.libs", from_tty=0) at ../../gdb/main.c:379
#11 0x00005555558fdb92 in captured_main_1 (python_script=<synthetic pointer>: <optimized out>, context=0x7fffffffe430)
    at ../../gdb/main.c:1206
#12 captured_main (data=0x7fffffffe430) at ../../gdb/main.c:1230
#13 gdb_main (args=0x7fffffffe430) at ../../gdb/main.c:1268
#14 0x000055555567103b in main (argc=<optimized out>, argv=<optimized out>) at ../../gdb/gdb.c:40

Comment 1 Jan Kratochvil 2018-02-04 21:44:16 UTC
It is now fixed in Rawhide GIT:
  [patch+8.1] Fix -D_GLIBCXX_DEBUG gdb-add-index regression
  https://sourceware.org/ml/gdb-patches/2018-02/msg00057.html
just I cannot build new Rawhide GDB now:
  Re: Rawhide buildroot broken?
  https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/AJYUOVPS26NE7TQWVNR7HPXZXOCUC66J/


Note You need to log in before you can comment on or make changes to this bug.