[PATCH] Allow out-of-order reads of CIEs
Tom Tromey
tromey@adacore.com
Fri Oct 25 14:29:00 GMT 2019
>>>>> "Tom" == Tom Tromey <tromey@adacore.com> 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 <tromey@adacore.com>
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
More information about the Gdb-patches
mailing list