From patchwork Sun Feb 4 19:37:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 25789 Received: (qmail 94946 invoked by alias); 4 Feb 2018 19:38:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 94929 invoked by uid 89); 4 Feb 2018 19:38:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 04 Feb 2018 19:38:01 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 294DD80F79; Sun, 4 Feb 2018 19:38:00 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D36FC60C95; Sun, 4 Feb 2018 19:37:56 +0000 (UTC) Date: Sun, 4 Feb 2018 20:37:54 +0100 From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Simon Marchi , Sergio Durigan Junior Subject: [patch+8.1] Fix -D_GLIBCXX_DEBUG gdb-add-index regression Message-ID: <20180204193754.GA29011@host1.jankratochvil.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) 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 > > >, std::__debug::vector > > > (mutable iterator); state = past-the-end; references sequence with type 'std::__debug::vector > >' @ 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 >; } 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 Date: Mon Jun 12 16:29:53 2017 +0100 Code cleanup: C++ify .gdb_index producer commit af5bf4ada48ff65b6658be1fab8f9c8f8ab5f319 Author: Simon Marchi 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 * 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 --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 51d0f39f75..d38a8477f2 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -25581,7 +25581,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; @@ -26015,12 +26015,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); @@ -26070,12 +26072,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); } @@ -26266,10 +26268,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); } @@ -26627,11 +26629,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);