[PATCH] D66901: [ObjectYAML] Fix lifetime issue in dumpDebugLines

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 28 13:04:51 PDT 2019


vitalybuka marked 2 inline comments as done.
vitalybuka added inline comments.


================
Comment at: llvm/tools/obj2yaml/dwarf2yaml.cpp:288
       const uint64_t LineEnd =
           LineTableLength + *StmtOffset + SizeOfPrologueLength;
+      DWARFYAML::LineTableOpcode NewOp = {};
----------------
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.

 


================
Comment at: llvm/tools/obj2yaml/dwarf2yaml.cpp:290
       while (Offset < LineEnd) {
-        DWARFYAML::LineTableOpcode NewOp;
         NewOp.Opcode = (dwarf::LineNumberOps)LineData.getU8(&Offset);
----------------
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.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66901/new/

https://reviews.llvm.org/D66901





More information about the llvm-commits mailing list