5

I've been trying to locate where a segmentation fault is in a program using LLDB. I've been going to the Ubuntu shell on repl.it and compiling my code using clang++-7 -pthread -std=c++17 -o main main.cpp -g and the program compiles succesfully. Next, I run lldb main and everything's fine but as soon as I type run I get error: process launch failed: 'A' packet returned an error: 8. I've checked the docs and looked up the error but I can't seem to find anything. Thanks for any sort of help!

The full log:

~/Project$ clang++-7 -pthread -std=c++17 -o main main.cpp -g
~/Project$ lldb main
(lldb) target create "main"
Current executable set to 'main' (x86_64).
(lldb) run
error: process launch failed: 'A' packet returned an error: 8

In case you need the code it's on this Github: https://github.com/KingsleyDockerill/Wirth

Dock
  • 444
  • 5
  • 13
  • 1
    Are you by any chance using WSL (Windows Subsystem for Linux)? – dfrib Sep 22 '21 at 21:00
  • @dfrib I do not think I am. I'm using the website repl.it and it's console so there's chance – Dock Sep 22 '21 at 21:22
  • 1
    Sounds like an environment issue: e.g. [this post](https://replit.com/talk/ask/C-debugging/17260) on repl.it mentions exactly the same lldb error, and one answer questions whether repl.it supports debugging with lldb and/or gdb. – dfrib Sep 22 '21 at 21:32
  • 2
    The error means that the debugger wasn't allowed to launch the process for debugging. Make sure the process launches outside the debugger, but if it does, then likely debugging is the issue. IIRC as a security measure, you can configure Linux systems to allow debugging or to not allow debugging. At some point, for instance, the default for Docker images was to NOT allow debugging, though I don't know if that's still true. You might check to make sure the system you are using is set up to allow debugging. – Jim Ingham Sep 24 '21 at 20:00
  • 6
    Those coming here from Google - If you are running on docker, [this is your answer](https://stackoverflow.com/a/70108776/913098) – Gulzar Nov 25 '21 at 09:47

1 Answers1

7

For those using Docker, as mentioned here, they need to add --cap-add=SYS_PTRACE --security-opt seccomp=unconfined to their docker run command in order to use lldb.

for devcontainer add these properties

{
  "capAdd": ["SYS_PTRACE"],
  "securityOpt": ["seccomp=unconfined"]
}

See also this older answer.

mdmundo
  • 1,988
  • 2
  • 23
  • 37