bloomberg / memray

Memray is a memory profiler for Python
https://bloomberg.github.io/memray/
Apache License 2.0
13.17k stars 392 forks source link

memray attach fails #443

Closed shrfb closed 1 year ago

shrfb commented 1 year ago

Is there an existing issue for this?

Current Behavior

When trying to attach a to python process, it fails with:

thread #287, name = 'ThrdSchedProv5', stop reason = signal SIGSTOP frame #0: 0x00007f5e30d259d9 -> 0x7f5e30d259d9: cmpq $-0xfff, %rax ; imm = 0xF001 0x7f5e30d259df: jae 0x7f5e30d259e2 0x7f5e30d259e1: retq 0x7f5e30d259e2: movq 0xed40f(%rip), %rcx Architecture set to: x86_64-unknown-linux-gnu. (lldb) expr char $libpath[]="/usr/lib64/python3.9/site-packages/memray/inject.abi3.so" error: Could not find entry point address for primary executable module "$__lldb_valid_pointer_check"

Failed to execute our lldb script. Run with --verbose to debug the failure.

Expected Behavior

process attach should work.

Steps To Reproduce

1) ps -ef to grab a process pid 2) memray attach pid

Memray Version

1.9.1

Python Version

3.9

Operating System

Linux

Anything else?

No response

godlygeek commented 1 year ago

Hi @shrfb - can you give us any details about how to reproduce this issue? What version of lldb are you running? What Linux distro/version? Does it fail every time you try, or only sometimes?

We've seen LLDB on Linux being a lot flakier than GDB, so installing the gdb package might get memray attach working for you. But, unless you can tell us how to reproduce the issue you're having, there's not much we can do to fix it.

shrfb commented 1 year ago

On the machine both lldb and gdb are installed. How can i force the use of gdb?

godlygeek commented 1 year ago

You can force it with:

memray attach --method=gdb pid

By default we prefer lldb over gdb if it's installed, but perhaps we ought make that conditional on the platform and prefer gdb over lldb on Linux...

godlygeek commented 1 year ago

That said, both methods are supposed to work if the relevant tool is available, so any extra information you can give us about your environment might be able to help us figure out why the lldb approach isn't working.

godlygeek commented 1 year ago

There's nothing we can do to fix this without knowing how to reproduce the failure.