Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>, <gdb-patches@sourceware.org>
Cc: Sergio Durigan Junior <sergiodj@redhat.com>
Subject: Re: [patch+8.1] Fix -D_GLIBCXX_DEBUG gdb-add-index regression
Date: Thu, 12 Apr 2018 19:21:00 -0000	[thread overview]
Message-ID: <cd1a0a8e-6b5e-ed16-e170-ebb2abddefab@ericsson.com> (raw)
In-Reply-To: <20180204193754.GA29011@host1.jankratochvil.net>

Hi Jan,

Sorry I missed this patch, but found out about it from your bug report.

On 2018-02-04 02:37 PM, Jan Kratochvil wrote:
> Hi,
> 
> gdb: Out-of-bounds vector access while running gdb-add-index
> https://bugzilla.redhat.com/show_bug.cgi?id=1540559
> 
> Fedora Rawhide started to use -D_GLIBCXX_DEBUG which made gdb-add-index
> failing.
> 
> /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*> >;
>     }
> 
> I do not know if anyone regression-tests GDB with -D_GLIBCXX_DEBUG,
> I have just checked -D_GLIBCXX_DEBUG run against gdb-add-index.

I didn't know about this before you reported those bugs.  I've added it to my
build, and suggested to Sergio that we add it to the buildbot.

> 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
> 
> No regressions on {x86_64,x86_64-m32,i686}-fedorarawhide-linux-gnu.
> 
> OK for check-in?

LGTM.  But that code has moved to dwarf-index-write.c, and I feel bad
because your patch was posted way before the move.  So I adjusted it
to save you a bit of time (please make sure I didn't mess up anything).


From 0f437317476d4eacf220c03f58baaf595a5c0cee Mon Sep 17 00:00:00 2001
From: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Sun, 4 Feb 2018 20:37:54 +0100
Subject: [PATCH] Fix -D_GLIBCXX_DEBUG gdb-add-index regression

Hi,

gdb: Out-of-bounds vector access while running gdb-add-index
https://bugzilla.redhat.com/show_bug.cgi?id=1540559

Fedora Rawhide started to use -D_GLIBCXX_DEBUG which made gdb-add-index
failing.

/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*> >;
    }

I do not know if anyone regression-tests GDB with -D_GLIBCXX_DEBUG,
I have just checked -D_GLIBCXX_DEBUG run against gdb-add-index.

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

No regressions on {x86_64,x86_64-m32,i686}-fedorarawhide-linux-gnu.

OK for check-in?

Jan

gdb/ChangeLog
2018-02-04  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* 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.
---
 gdb/dwarf-index-write.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/gdb/dwarf-index-write.c b/gdb/dwarf-index-write.c
index 4c596c2..a5e196d 100644
--- a/gdb/dwarf-index-write.c
+++ b/gdb/dwarf-index-write.c
@@ -154,7 +154,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;
@@ -588,12 +588,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);

@@ -643,12 +645,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);
 }
@@ -839,10 +841,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);
   }

@@ -1200,11 +1202,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);

-- 
2.7.4



  reply	other threads:[~2018-04-12 19:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-04 19:38 Jan Kratochvil
2018-04-12 19:21 ` Simon Marchi [this message]
2018-04-12 19:41   ` Sergio Durigan Junior
2018-04-12 20:37     ` buildbot false warning mails [Re: [patch+8.1] Fix -D_GLIBCXX_DEBUG gdb-add-index regression] Jan Kratochvil
2018-04-12 20:45       ` Sergio Durigan Junior
2018-04-12 20:39   ` [commit+8.1] Fix -D_GLIBCXX_DEBUG gdb-add-index regression Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cd1a0a8e-6b5e-ed16-e170-ebb2abddefab@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=sergiodj@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox