Page MenuHomePhabricator

Fix a crash when parsing incorrect DWARF
ClosedPublic

Authored by labath on Nov 12 2018, 2:00 AM.

Details

Summary

While parsing a childless compile unit DIE we could crash if the DIE was
followed by any extra data (such as a superfluous end-of-children
marker). This happened because the break-on-depth=0 check was performed
only when parsing the null DIE, which was not correct because with a
childless root DIE, we could reach the end of the unit without ever
encountering the null DIE.

If the compile unit contribution ended directly after the CU DIE,
everything would be fine as we would terminate parsing due to reaching
EOF. However, if the contribution contained extra data (perhaps a
superfluous end-of-children marker), we would crash because we would
treat that data as the begging of another compile unit.

This fixes the crash by moving the depth=0 check to a more generic
place, and also adds a regression test.

Event Timeline

labath created this revision.Nov 12 2018, 2:00 AM
JDevlieghere accepted this revision.Nov 12 2018, 9:42 AM

Your explanation makes sense, good catch. Thanks for fixing this!

This revision is now accepted and ready to land.Nov 12 2018, 9:42 AM
clayborg accepted this revision.Nov 12 2018, 10:15 AM
jankratochvil accepted this revision.Nov 12 2018, 10:57 AM
This revision was automatically updated to reflect the committed changes.