Allow out-of-order reads of CIEs
authorTom Tromey <tromey@adacore.com>
Tue, 8 Oct 2019 20:35:24 +0000 (14:35 -0600)
committerTom Tromey <tromey@adacore.com>
Fri, 25 Oct 2019 14:29:44 +0000 (08:29 -0600)
commit93878f471745364756b9bad753c5052614fbcd7e
treef5a973353f040fb4dad40b80c5225eb24c9a5c23
parent52c64cf72d40aace2d2fedca32e5c0373cd9a484
Allow out-of-order reads of CIEs

Currently gdb has an assertion that requires CIEs to be read in the
order in which they appear in the debug info:

   gdb_assert (n < 1
               || cie_table->entries[n - 1]->cie_pointer < cie->cie_pointer);

This assertion ensures that the table will be sorted, which is
important because it is later searched using bsearch.

However, a customer provided an executable that causes this assertion
to trigger.  This executable causes decode_frame_entry_1 to call
decode_frame_entry to find the CIE, resulting in an out-of-order read.

I don't know a good way to construct a reproducer, but this can happen
if the FDE appears before its CIE.  See
https://sourceware.org/bugzilla/show_bug.cgi?id=16563

This patch fixes the problem by storing CIEs in an unordered map.  The
CIE table is discarded after the frame section is parsed, so this
seemed both simple and straightforward.

gdb/ChangeLog
2019-10-25  Tom Tromey  <tromey@adacore.com>

* dwarf2-frame.c (dwarf2_cie_table): Now a typedef.
(bsearch_cie_cmp, add_cie): Remove.
(find_cie): Reimplement.
(decode_frame_entry_1, decode_frame_entry): Change type.  Update.
(dwarf2_build_frame_info): Update.

Change-Id: I4a99597fa4b1398a9d105b683a36d992d506485c
gdb/ChangeLog
gdb/dwarf2-frame.c
This page took 0.026902 seconds and 4 git commands to generate.