debugger icon indicating copy to clipboard operation
debugger copied to clipboard

lldb-server deletes the debugged binary when doing remote debugging on local host

Open ceres-c opened this issue 2 years ago • 4 comments

I'm trying to use binja debugger with a debug server (the preferred way to do it, according to the docs here), but it deletes the file I'm trying to debug.

Test case:

  1. Open any binary in binary ninja (in this example, the standard ls binary from my distro)
  2. Start lldb-server in the same folder lldb-server p --server --listen 0.0.0.0:31337
  3. Connect to debug server (Debug -> Connect to debug server -> Platform: remote-linux | Host: 127.0.0.1 | Port: 31337)
  4. Connection succeeds
  5. Go to debugger menu on the left panel, start debugging

In the log I get LLDB Failed to launch target with "error: No such file or directory" and debug is not started. The file is now gone. If I try to start debugging again, I get a different error message: LLDB Failed to create target with "'/home/federico/tmp_binja/ls' does not exist". Indeed the file does not exist anymore

Env: Arch linux on x86-64 Binary ninja 3.3.3996 lldb-server 15.0.7

I tried to run with --debug, but I don't get any additional debug output in the terminal other than the aforementioned errors that I also had in the log panel in the GUI. Let me know if I can help you with additional tests

Federico/ceres-c

ceres-c avatar Apr 10 '23 18:04 ceres-c

Thx for the report!

This looks weird, I know LLDB sometimes try to upload the debuggee to the remote host unexpectedly, though I have never seen anything like it deletes the binary. I will see if I can reproduce it and follow-up.

xusheng6 avatar Apr 11 '23 14:04 xusheng6

I ran into this today. It sounds like the issue is the target directory in the same as the local directory, and lldb erroneously deletes the file while trying to write to it

xusheng6 avatar Sep 02 '25 02:09 xusheng6

Related https://github.com/Vector35/debugger/issues/780#issuecomment-3248192755

xusheng6 avatar Sep 03 '25 09:09 xusheng6

@ceres-c I think this could only happen when you are doing remote debugging on the local host, is that your case?

If so, I am curious why you did that? Is that because you needed to run the lldb-server with root? Or is there any other reason that you need to do that?

xusheng6 avatar Sep 03 '25 09:09 xusheng6