[all-commits] [llvm/llvm-project] 1ae8d8: [libunwind] Fix memory leak in handling of DW_CFA_...

Jorge Gorbe Moya via All-commits all-commits at lists.llvm.org
Tue Feb 18 11:57:40 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 1ae8d81147a0724cc972054afbd72943032e4832
      https://github.com/llvm/llvm-project/commit/1ae8d81147a0724cc972054afbd72943032e4832
  Author: Jorge Gorbe Moya <jgorbe at google.com>
  Date:   2020-02-18 (Tue, 18 Feb 2020)

  Changed paths:
    M libunwind/src/DwarfParser.hpp
    A libunwind/test/remember_state_leak.pass.sh.s

  Log Message:
  -----------
  [libunwind] Fix memory leak in handling of DW_CFA_remember_state and DW_CFA_restore_state

parseInstructions() doesn't always process the whole set of DWARF
instructions for a frame. It will stop once the target PC is reached, or
if malformed instructions are found. So, for example, if we have an
instruction sequence like this:

```
<start>
...
DW_CFA_remember_state
...
DW_CFA_advance_loc past the location we're unwinding at (pcoffset in parseInstructions() main loop)
...
DW_CFA_restore_state
<end>
```

... the saved state will never be freed, even though the
DW_CFA_remember_state opcode has a matching DW_CFA_restore_state later
in the sequence.

This change adds code to free whatever is left on rememberStack after
parsing the CIE and the FDE instructions.

Differential Revision: https://reviews.llvm.org/D66904




More information about the All-commits mailing list