From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 77283 invoked by alias); 25 Oct 2019 14:29:28 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 77270 invoked by uid 89); 25 Oct 2019 14:29:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=cie, discarded, customer X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 Oct 2019 14:29:27 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 1145F5602B; Fri, 25 Oct 2019 10:29:26 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id SZUi-jWxFw4r; Fri, 25 Oct 2019 10:29:26 -0400 (EDT) Received: from murgatroyd (75-166-66-104.hlrn.qwest.net [75.166.66.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id A1E345602A; Fri, 25 Oct 2019 10:29:25 -0400 (EDT) From: Tom Tromey To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Allow out-of-order reads of CIEs References: <20191011134930.4279-1-tromey@adacore.com> Date: Fri, 25 Oct 2019 14:29:00 -0000 In-Reply-To: <20191011134930.4279-1-tromey@adacore.com> (Tom Tromey's message of "Fri, 11 Oct 2019 07:49:30 -0600") Message-ID: <878sp8q4or.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2019-10/txt/msg00912.txt.bz2 >>>>> "Tom" == Tom Tromey writes: Tom> Currently gdb has an assertion that requires CIEs to be read in the Tom> order in which they appear in the debug info: Tom> gdb_assert (n < 1 Tom> || cie_table->entries[n - 1]->cie_pointer < cie->cie_pointer); Tom> This assertion ensures that the table will be sorted, which is Tom> important because it is later searched using bsearch. Tom> However, a customer provided an executable that causes this assertion Tom> to trigger. This executable causes decode_frame_entry_1 to call Tom> decode_frame_entry to find the CIE, resulting in an out-of-order read. Tom> I don't know a good way to construct a reproducer, but this can happen Tom> if the FDE appears before its CIE. See Tom> https://sourceware.org/bugzilla/show_bug.cgi?id=16563 Tom> This patch fixes the problem by storing CIEs in an unordered map. The Tom> CIE table is discarded after the frame section is parsed, so this Tom> seemed both simple and straightforward. Tom> gdb/ChangeLog Tom> 2019-10-11 Tom Tromey Tom> * dwarf2-frame.c (dwarf2_cie_table): Now a typedef. Tom> (bsearch_cie_cmp, add_cie): Remove. Tom> (find_cie): Reimplement. Tom> (decode_frame_entry_1, decode_frame_entry): Change type. Update. Tom> (dwarf2_build_frame_info): Update. I'm checking this in now. Tom