[Bug 48237] New: Memory leak, when executing expressions

Bug ID 48237
Summary Memory leak, when executing expressions
Product lldb
Version 11.0
Hardware PC
OS Linux
Status NEW
Severity normal
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter mplaneta@os.inf.tu-dresden.de
CC jdevlieghere@apple.com, llvm-bugs@lists.llvm.org

Hello,

When I attach to a process and executes some expressions, lldb allocates memory
to JIT-compile the code inside the process address space. Unfortunately, lldb
does not clean up this memory upon exit.

## How to reproduce

I create a multithreaded program 'victim-malloc' that makes free(malloc()) in a
busy loop. First, I let the program run, then I record the memory map of the
program:

    $ cat  /proc/$(pidof victim-malloc)/maps > /tmp/a

I attach to the program using lldb and run an expression

    $ lldb-11 -p $(pidof victim-malloc)
    (lldb) expression -- (int) printf("Hello");

I exit from lldb, record the memory map second time and look at the diff.

    $ cat  /proc/$(pidof victim-malloc)/maps > /tmp/b
    $ diff -p /tmp/a /tmp/b

Here is the result:

*** /tmp/a      2020-11-20 10:21:25.434149021 +0100
--- /tmp/b      2020-11-20 10:22:35.098652870 +0100