From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 226773858406; Fri, 1 Oct 2021 15:10:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 226773858406 From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug gdb/28404] Verify bsearch precondition in find_pc_section Date: Fri, 01 Oct 2021 15:10:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Oct 2021 15:10:08 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28404 --- Comment #1 from Tom de Vries --- I wrote this: ... diff --git a/gdb/objfiles.c b/gdb/objfiles.c index b65fa8820ca..cc9a47eaad8 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -1227,6 +1227,19 @@ find_pc_section (CORE_ADDR pc) return NULL; } + { + struct obj_section *prev_elem =3D nullptr; + struct obj_section *elem =3D nullptr; + for (int i =3D 0; i < pspace_info->num_sections; (prev_elem =3D elem),= ++i) + { + elem =3D pspace_info->sections[i]; + gdb_assert (elem->addr () <=3D elem->endaddr ()); + if (prev_elem =3D=3D nullptr) + continue; + gdb_assert (prev_elem->endaddr () <=3D elem->addr ()); + } + }re-- + sp =3D (struct obj_section **) bsearch (&pc, pspace_info->sections, pspace_info->num_sections, ...=20 And tested using target board unix/-fPIE/-pie. No regression. So, I guess I was looking at the consequences of the patch series I was pla= ying around with. --=20 You are receiving this mail because: You are on the CC list for the bug.=