This is an archive of the discontinued LLVM Phabricator instance.

[ObjectYAML] Fix lifetime issue in dumpDebugLines
ClosedPublic

Authored by vitalybuka on Aug 28 2019, 12:54 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

vitalybuka created this revision.Aug 28 2019, 12:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 28 2019, 12:54 PM
vitalybuka marked 2 inline comments as done.Aug 28 2019, 1:02 PM
vitalybuka added inline comments.
llvm/tools/obj2yaml/dwarf2yaml.cpp
288 ↗(On Diff #217704)

If we move it outside of the loop tests still work.
However NewOp contains two std::vector first which previously were initialized on every iteration.

290 ↗(On Diff #217704)

On a first look it should be safe just

DWARFYAML::LineTableOpcode NewOp = {};

However after that we fail tests:

******************** TEST 'LLVM :: ObjectYAML/MachO/DWARF-debug_line.yaml' FAILED ********************
Script:
--
: 'RUN: at line 1';   /usr/local/google/home/vitalybuka/src/llvm.git/out/a/bin/yaml2obj /usr/local/google/home/vitalybuka/src/llvm.git/llvm-project/llvm/test/ObjectYAML/MachO/DWARF-debug_line.yaml | /usr/local/google/home/vitalybuka/src/llvm.git/out/a/bin/obj2yaml | /usr/local/google/home/vitalybuka/src/llvm.git/out/a/bin/FileCheck /usr/local/google/home/vitalybuka/src/llvm.git/llvm-project/llvm/test/ObjectYAML/MachO/DWARF-debug_line.yaml
--
Exit Code: 1
Command Output (stderr):
--
/usr/local/google/home/vitalybuka/src/llvm.git/llvm-project/llvm/test/ObjectYAML/MachO/DWARF-debug_line.yaml:560:9: error: CHECK: expected string not found in input
#CHECK: Data: 4294971216
        ^
<stdin>:534:2: note: scanning from here
 Data: 0
 ^
<stdin>:546:2: note: possible intended match here
 Data: 11
 ^

So looks like code expects data from the previos iteration.

beanz added inline comments.Aug 28 2019, 1:19 PM
llvm/tools/obj2yaml/dwarf2yaml.cpp
290 ↗(On Diff #217704)

This looks to me like an error in the test case, but I could be wrong. It has been a long time since I dug in DWARF, but I'm pretty sure our YAML is attaching data to opcodes that don't have data fields, and the old code was re-using the values from the previous iteration of the loop, which seems wrong.

proper fix and test update

vitalybuka marked an inline comment as done.Aug 28 2019, 1:44 PM

That's I suspected as well but I din't realize that input of the test was probably generated with that bug :).
Please stamp the patch so we can fix the bot.

beanz accepted this revision.Aug 28 2019, 6:10 PM
This revision is now accepted and ready to land.Aug 28 2019, 6:10 PM
This revision was automatically updated to reflect the committed changes.