https://bugs.llvm.org/show_bug.cgi?id=46900

            Bug ID: 46900
           Summary: MCContext untyped bump allocator not suitable for
                    MCInst.
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: hgrev...@google.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org

Created attachment 23789
  --> https://bugs.llvm.org/attachment.cgi?id=23789&action=edit
Small reproducer

Allocating MCInst with MCContext's overloaded 'new' can lead to a memory leak.

The reason is that MCInst contains a SmallVector<MCOperand, 8>. The SmallVector
is POD only for <= 8 operands. The default untyped bump pointer allocator of
MCContext does not delete the MCInst.

Small reproducer:

./llvm-project/install/bin/clang++ -O0 -g3 -c -o mcinst.o
`./llvm-project/install/bin/llvm-config --cxxflags` -fsanitize=address
mcinst.cc

./llvm-project/install/bin/clang++ mcinst.o
`./llvm-project/install/bin/llvm-config --ldflags --libs` -lpthread -ltinfo
-ldl -lz -fsanitize=address -o mcinst

ASAN_SYMBOLIZER_PATH=./llvm-project/install/bin/llvm-symbolizer ./test

Thanks to Marcello Maggioni and Thomas Raoux for helping to find this.

Suggested patch:

https://reviews.llvm.org/D84896

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to