[PATCH] D12805: [mips] Save a copy of MipsABIInfo in the MipsTargetStreamer to escape a dangling pointer

Daniel Sanders via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 02:10:13 PDT 2015


dsanders accepted this revision.
dsanders added a comment.
This revision is now accepted and ready to land.

Hmm. MipsAsmPrinter is supposed to be delivering the ABI information for that path and it looks like it's still alive since AsmPrinter::doFinalization() is in the call stack at the point of the bad read. However, valgrind is clearly showing the invalid read occurred in memory belonging to a dead MipsAsmParser.

The MipsAsmParser presumably only exists because it's needed to parse the asm statement. My guess is that what's happening is MipsAsmPrinter delivers the ABI information as it's supposed to, then MipsAsmParser is constructed and substitutes its own MipsABIInfo pointer. MipsAsmParser is then destroyed, leaving a dangling pointer. Meanwhile, the pointer to MipsAsmPrinter's MipsABIInfo remains valid.

The target triples project will be able to solve this nicely since we'll be able to consult the longer-lived TargetTuple but we shouldn't make this fix depend on that. This patch seems reasonable in the mean time. LGTM


Repository:
  rL LLVM

http://reviews.llvm.org/D12805





More information about the llvm-commits mailing list