This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb/gdb-8.1-branch] Fix -D_GLIBCXX_DEBUG gdb-add-index regression
- From: Jan Kratochvil <jkratoch at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 12 Apr 2018 20:37:56 -0000
- Subject: [binutils-gdb/gdb-8.1-branch] Fix -D_GLIBCXX_DEBUG gdb-add-index regression
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=55404da3795df1b5eff514ce9d0377b6a78e5904
commit 55404da3795df1b5eff514ce9d0377b6a78e5904
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Thu Apr 12 22:31:39 2018 +0200
Fix -D_GLIBCXX_DEBUG gdb-add-index regression
Fedora Rawhide started to use -D_GLIBCXX_DEBUG which made gdb-add-index
failing:
gdb: Out-of-bounds vector access while running gdb-add-index
https://bugzilla.redhat.com/show_bug.cgi?id=1540559
/usr/include/c++/7/debug/safe_iterator.h:270:
Error: attempt to dereference a past-the-end iterator.
Objects involved in the operation:
iterator "this" @ 0x0x7fffffffcb90 {
type = __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<unsigned char*, std::__cxx1998::vector<unsigned char, gdb::default_init_allocator<unsigned char, std::allocator<unsigned char> > > >, std::__debug::vector<unsigned char, gdb::default_init_allocator<unsigned char, std::allocator<unsigned char> > > > (mutable iterator);
state = past-the-end;
references sequence with type 'std::__debug::vector<unsigned char, gdb::default_init_allocator<unsigned char, std::allocator<unsigned char> > >' @ 0x0x7fffffffcc50
}
/usr/include/c++/7/debug/vector:417:
Error: attempt to subscript container with out-of-bounds index 556, but
container only holds 556 elements.
Objects involved in the operation:
sequence "this" @ 0x0x2e87af8 {
type = std::__debug::vector<partial_symbol*, std::allocator<partial_symbol*> >;
}
The two -D_GLIBCXX_DEBUG regressions were made by:
commit bc8f2430e08cc2a520db49a42686e0529be4a3bc
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Mon Jun 12 16:29:53 2017 +0100
Code cleanup: C++ify .gdb_index producer
commit af5bf4ada48ff65b6658be1fab8f9c8f8ab5f319
Author: Simon Marchi <simon.marchi@ericsson.com>
Date: Sat Oct 14 08:06:29 2017 -0400
Replace psymbol_allocation_list with std::vector
gdb/ChangeLog
2018-04-12 Jan Kratochvil <jan.kratochvil@redhat.com>
PR gdb/23053
* dwarf2read.c (data_buf::grow) (write_one_signatured_type)
(recursively_write_psymbols) (debug_names::recursively_write_psymbols)
(debug_names::write_one_signatured_type): Fix -D_GLIBCXX_DEBUG
regression.
Diff:
---
gdb/ChangeLog | 8 ++++++++
gdb/dwarf2read.c | 22 +++++++++++++---------
2 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 064780c..cc6dd9e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2018-04-12 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ PR gdb/23053
+ * dwarf2read.c (data_buf::grow) (write_one_signatured_type)
+ (recursively_write_psymbols) (debug_names::recursively_write_psymbols)
+ (debug_names::write_one_signatured_type): Fix -D_GLIBCXX_DEBUG
+ regression.
+
2018-03-01 Sergio Durigan Junior <sergiodj@redhat.com>
PR gdb/22907
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 59cbbaa..bd2bc7d 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -25539,7 +25539,7 @@ private:
gdb_byte *grow (size_t size)
{
m_vec.resize (m_vec.size () + size);
- return &*m_vec.end () - size;
+ return &*(m_vec.end () - size);
}
gdb::byte_vector m_vec;
@@ -25973,12 +25973,14 @@ write_one_signatured_type (void **slot, void *d)
write_psymbols (info->symtab,
info->psyms_seen,
- &info->objfile->global_psymbols[psymtab->globals_offset],
+ (info->objfile->global_psymbols.data ()
+ + psymtab->globals_offset),
psymtab->n_global_syms, info->cu_index,
0);
write_psymbols (info->symtab,
info->psyms_seen,
- &info->objfile->static_psymbols[psymtab->statics_offset],
+ (info->objfile->static_psymbols.data ()
+ + psymtab->statics_offset),
psymtab->n_static_syms, info->cu_index,
1);
@@ -26028,12 +26030,12 @@ recursively_write_psymbols (struct objfile *objfile,
write_psymbols (symtab,
psyms_seen,
- &objfile->global_psymbols[psymtab->globals_offset],
+ objfile->global_psymbols.data () + psymtab->globals_offset,
psymtab->n_global_syms, cu_index,
0);
write_psymbols (symtab,
psyms_seen,
- &objfile->static_psymbols[psymtab->statics_offset],
+ objfile->static_psymbols.data () + psymtab->statics_offset,
psymtab->n_static_syms, cu_index,
1);
}
@@ -26222,10 +26224,10 @@ public:
psyms_seen, cu_index);
write_psymbols (psyms_seen,
- &objfile->global_psymbols[psymtab->globals_offset],
+ objfile->global_psymbols.data () + psymtab->globals_offset,
psymtab->n_global_syms, cu_index, false, unit_kind::cu);
write_psymbols (psyms_seen,
- &objfile->static_psymbols[psymtab->statics_offset],
+ objfile->static_psymbols.data () + psymtab->statics_offset,
psymtab->n_static_syms, cu_index, true, unit_kind::cu);
}
@@ -26581,11 +26583,13 @@ private:
struct partial_symtab *psymtab = entry->per_cu.v.psymtab;
write_psymbols (info->psyms_seen,
- &info->objfile->global_psymbols[psymtab->globals_offset],
+ (info->objfile->global_psymbols.data ()
+ + psymtab->globals_offset),
psymtab->n_global_syms, info->cu_index, false,
unit_kind::tu);
write_psymbols (info->psyms_seen,
- &info->objfile->static_psymbols[psymtab->statics_offset],
+ (info->objfile->static_psymbols.data ()
+ + psymtab->statics_offset),
psymtab->n_static_syms, info->cu_index, true,
unit_kind::tu);