Skip to content

LLDB can't launch process #2028

Closed
Closed

Description

How to reproduce:
1. lldb /bin/ls
2. type "run"

Result:
1. LLDB reports error 8 [presumably ENOEXEC]
2. strace reports failed call to PTRACE_ME [possibly not relevant]

Log:

lldb /bin/ls
...
Current executable set to '/bin/ls' (x86_64).
(lldb) r
error: process launch failed: 'A' packet returned an error: 8

strace -f log:
[pid 4052] clone(strace: Process 4057 attached
child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, chi
ld_tidptr=0x7f677a120a10) = 4057
[pid 4057] set_robust_list(0x7f677a120a20, 24) = 0
[pid 4052] wait4(4057, <unfinished ...>
[pid 4057] setsid() = 4057
[pid 4057] ioctl(6, TCGETS, {B38400 opost isig icanon echo ...}) = 0
[pid 4057] ioctl(6, TIOCGPTN, [5]) = 0
[pid 4057] stat("/dev/pts/5", {st_mode=S_IFCHR|0620, st_rdev=makedev(136
, 5), ...}) = 0
[pid 4057] open("/dev/pts/5", O_RDWR) = 7
[pid 4057] close(6) = 0
[pid 4057] dup2(7, 0) = 0
[pid 4057] dup2(7, 1) = 1
[pid 4057] dup2(7, 2) = 2
[pid 4057] ptrace(PTRACE_TRACEME, 0, NULL, NULL) = -1 EPERM (Operation n
ot permitted)

[pid 4057] write(1, "using the default platform: host"..., 80) = 80
[pid 4057] exit_group(1) = ?
[pid 4057] +++ exited with 1 +++
[pid 4052] <... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 1}],
0, NULL) = 4057
[pid 4052] close(6) = 0
[pid 4052] rt_sigaction(SIGCHLD, {SIG_DFL, [CHLD], SA_RESTORER|SA_RESTAR
T, 0x7f6779341390}, NULL, 8) = 0
[pid 4052] rt_sigprocmask(SIG_BLOCK, [CHLD], NULL, 8) = 0
[pid 4052] write(2, "LaunchProcess: failed to launch "..., 50) = 50
[pid 4052] sendto(5, "$E08#ad", 7, 0, NULL, 0) = 7
[pid 4030] <... select resumed> ) = 1 (in [10], left {9, 980081})
[pid 4052] gettid( <unfinished ...>
[pid 4030] recvfrom(10, <unfinished ...>
[pid 4052] <... gettid resumed> ) = 4052
[pid 4030] <... recvfrom resumed> "$E08#ad", 8192, 0, NULL, NULL) = 7
[pid 4052] select(6, [3 5], NULL, NULL, {0, 0} <unfinished ...>
[pid 4030] gettid() = 4030
[pid 4052] <... select resumed> ) = 0 (Timeout)
[pid 4030] close(10 <unfinished ...>
[pid 4052] rt_sigprocmask(SIG_SETMASK, NULL, [HUP CHLD], 8) = 0
[pid 4030] <... close resumed> ) = 0
[pid 4052] pselect6(6, [5], NULL, NULL, NULL, {[CHLD], 8} <unfinished ..
.>
[pid 4030] close(6 <unfinished ...>
[pid 4052] <... pselect6 resumed> ) = 1 (in [5])
[pid 4030] <... close resumed> ) = 0
[pid 4052] select(6, [3 5], NULL, NULL, {0, 0} <unfinished ...>
[pid 4030] close(7 <unfinished ...>
[pid 4052] <... select resumed> ) = 1 (in [5], left {0, 0})
[pid 4030] <... close resumed> ) = 0
[pid 4052] recvfrom(5, <unfinished ...>
[pid 4030] kill(4052, SIGINT <unfinished ...>
[pid 4052] <... recvfrom resumed> "", 8192, 0, NULL, NULL) = 0
[pid 4030] <... kill resumed> ) = 0
[pid 4052] --- SIGINT {si_signo=SIGINT, si_code=SI_USER, si_pid=4030, si
_uid=1000} ---
[pid 4030] write(2, "error: process launch failed: 'A"..., 62error: proc

Windows build number: 10.0.15063

Activity

  1. therealkenc commented on Apr 28, 2017

    @therealkenc

    strace reports failed call to PTRACE_ME [possibly not relevant]

    Relevant. Critical, even. #555 #688 (message) #1692. This is what takes down Swift, because Apple is all about the clang these days.

  2. danmoseley commented on Jan 21, 2018

    @danmoseley

    Ben Hillis (@benhillis) is this something you're likely to fix? it breaks, in my case, debugging .NET Core on WSL - since it is not possible to debug C# using gdb as the SOS plugin is for lldb.

    cc Mike McLaughlin (@mikem8361)

  3. danmoseley commented on Jan 21, 2018

    @danmoseley

    This seems to prevent me even stopping at a breakpoint in gdb. This is on insider build 17074.

    dan@DESKTOP:/mnt/c/gcc$ gcc -o test -Wall test.c -g
    dan@DESKTOP:/mnt/c/gcc$ strace -f -o out2 gdb ./test
    GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
    ...
    Reading symbols from ./test...done.
    (gdb) break main
    Breakpoint 1 at 0x400875: file test.c, line 17.
    (gdb) run
    Starting program: /mnt/c/gcc/test
    During startup program exited normally.
    (gdb) q
    dan@DESKTOP:/mnt/c/gcc$ grep PTRACE out2
    7416  ptrace(PTRACE_TRACEME, 0, NULL, NULL) = -1 EPERM (Operation not permitted)
    

    Am I missing something ? From looking at other issues, etc, it seems gdb should work.

  4. therealkenc commented on Jan 21, 2018

    @therealkenc

    @danmosemsft - No that's new. Wish github had a sad emoji to go with the others. Wonder what changed. It's either a WSL regression, or a gdb modification. I am going to place my Internet nickle on the latter, given your very helpful strace grep (appreciated, we don't get that a lot around here). Or we are both missing something obvious.

    If anyone is out there on FCU 16299 and can give it a quick go it would be appreciated. Make sure you are running gdb 7.11.1.

    [edit] That PTRACE_TRACEME EPERM is "normal" in the scenario; same behaviour Real Linux. Nickle withdrawn. We'll have to see how this plays out.

  5. danmoseley commented on Jan 21, 2018

    @danmoseley

    therealkenc so you confirm you get the same result, you cannot debug hello world with gdb?

  6. therealkenc commented on Jan 21, 2018

    @therealkenc

    That's correct. Unless we are both missing something obvious. Which is always a nonzero possibility. I hadn't actually run gdb on WSL for a little while but it worked previously natch, or people's heads would explode. If there is something to this, the me2s will roll in. I don't have a FCU handy or I'd have something more concrete to offer. If it is a regression this is probably the wrong issue for that though.

  7. Brian-Perkins commented on Jan 22, 2018

    @Brian-Perkins
    Contributor

    This may be related to the memory management issued mentioned here. You can confirm by retaining ASLR behavior (set disable-randomization off).

  8. therealkenc commented on Jan 22, 2018

    @therealkenc

    Thanks; if I was more on the ball I would have connected that.

    sudo sh -c "echo '0' >> /proc/sys/kernel/randomize_va_space" results in badness here on 17074. The tty seems live but shell commands don't execute. After closing the cmd window, attempting to start ubuntu.exe again just returns with no error. Best to sit tight for the fix probably.

  9. danmoseley commented on Jan 22, 2018

    @danmoseley

    I just tried 16299.192 and it works fine.

    dan@danmose2:~/gcc$ gdb ./test
    GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
    ...
    Reading symbols from ./test...done.
    (gdb) break main
    Breakpoint 1 at 0x40052a: file test.c, line 5.
    (gdb) run
    Starting program: /home/dan/gcc/test
    
    Breakpoint 1, main () at test.c:5
    5           printf("Hello world\n");
    

    therealkenc I interpreted Brian Perkins (@Brian-Perkins) to mean just do set disable-randomization off before run in gdb, rather than globally. I'll try that when I get back to my 17074 box.

  10. danmoseley commented on Jan 22, 2018

    @danmoseley

    I've opened a new issue for this GDB issue since apparently it's different to the LLDB issue.
    #2870

  11. Brian-Perkins commented on Jan 22, 2018

    @Brian-Perkins
    Contributor

    Apologies -- I did mean only for GDB, but randomize_va_space is not persisted so it should eventually recover (probably a background process keeping the WSL instance active). The GDB setting is to turn ASLR on -- it is just done in the easy to follow double negative form: disable* off

  12. luser commented on Mar 16, 2018

    @luser

    FYI I opened a new issue specifically for PTRACE_SEIZE: #3031

  13. roozbehid commented on May 15, 2018

    @roozbehid

    I noticed the same issue with LLDB in docker which you can solve by adding "--privileged" to docker.

  14. firewave commented on Jul 10, 2018

    @firewave

    Using lldb-6.0 I have a different behavior on Kali:

    lldb-6.0 /bin/ls
    (lldb) target create "/bin/ls"
    Current executable set to '/bin/ls' (x86_64).
    (lldb) run
    Process 27347 launched: '/bin/ls' (x86_64)
    

    After that it appears to be stuck and is not doing anything (i.e. breakpoints are not hit). If I hit CTRL-C the process exits

    Process 27347 exited with status = -1 (0xffffffff) lost connection
    (lldb)
    

    When I start it in strace I sometimes get the same error as in the initial report

    error: process launch failed: 'A' packet returned an error: 8
    

    I checked the strace output and saw a few things but they all occurred before the process was even launched

    ioctl(3, TCGETS, 0x7fffd1052980)        = -1 ENOTTY (Inappropriate ioctl for device)
    ioctl(3, TCGETS, 0x7fffd10527a0)        = -1 ENOTTY (Inappropriate ioctl for device) 
    ...
    clone(child_stack=0x7f2054bdff70, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f2054be09d0, tls=0x7f2054be0700, child_tidptr=0x7f2054be09d0) = 27610
    futex(0x7fffc8ec65b0, FUTEX_WAIT_PRIVATE, 0, NULL) = -1 EAGAIN (Resource temporarily unavailable)
    futex(0x7fffc8ec6560, FUTEX_WAKE_PRIVATE, 1) = 0 
    

    Complete strace out:
    strace.log

    I am using 17134.137

  15. mokonzi131 commented on Jul 27, 2018

    @mokonzi131

    I'm having the exact same issue as Oliver Stöneberg (@firewave) on Ubuntu on Windows 17134

  16. DnOberon commented on Aug 7, 2018

    @DnOberon

    Running into the same issues, specifically with the delve debugger for Go an issue which therealkenc referenced.

  17. JCMais commented on Apr 2, 2019

    @JCMais

    I'm having the same issue, has anyone found a workaround?

  18. ikulagin commented on May 27, 2019

    @ikulagin

    Is there any news on this issue?

  19. ikulagin commented on Jun 14, 2019

    @ikulagin

    In WSL2 this issue is fixed.

  20. JCMais commented on Jun 15, 2019

    @JCMais

    Ivan Kulagin (@ikulagin) is WSL2 already available? How were you able to test it? Insiders build?

  21. devsnek commented on Jun 15, 2019

    @devsnek

    build 18917 has wsl2. once you have it you can follow these instructions: https://docs.microsoft.com/en-gb/windows/wsl/wsl2-install

    (i can also confirm that wsl2 fixes this issue, has been great)

  22. Qix- commented on Aug 6, 2020

    @Qix-

    Unless I'm mistaken and am not on WSL2, this still seems to be an issue for me on lldb even with WSL2.

    error: 'proc' is not an existing command.
    (lldb) target create "./test"
    Current executable set to '/tmp/test' (x86_64).
    (lldb) run
    Process 7242 launched: '/tmp/test' (x86_64)
    Process 7242 exited with status = -1 (0xffffffff) lost connection
    

    However, gdb works as expected.

  23. therealkenc commented on Aug 6, 2020

    @therealkenc

    Thanks for the report, Josh Junon (@Qix-).

    this still seems to be an issue

    This does not.

    image

    PTRACE_TRACEME is okay for sure. #3031 PTRACE_SEIZE is okay these days too. But do feel encouraged to open a new issue under a different cover if you think there is some diverge. There might be; if so I'll take a close look. You can verify you're on WSL2 with cat /proc/version. It'll look something like mine (with kernel 4.19.x and lower-case microsoft) if you are.

  24. jdknox commented on Sep 13, 2020

    @jdknox

    This doesn't seem fixed for me on WSL2. It can run in gdb even though it won't load debug symbols. But it gets a permission error on PTRACE_TRACEME in lldb. Running with sudo gives the same 'A' packet error.

    $ cat /proc/version
    Linux version 4.19.104-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Wed Feb 19 06:37:35 UTC 2020

    $ cmd.exe /c ver
    Microsoft Windows [Version 10.0.19041.508]

    --
    $ lldb a.exe

    (lldb) target create "a.exe"
    Current executable set to '/home/knox/w/handmade/src/c/a.exe' (x86_64).
    (lldb) run
    error: process launch failed: 'A' packet returned an error: -1
    

    strace -f log:
    3347 ptrace(PTRACE_TRACEME) = -1 EPERM (Operation not permitted)
    3347 lseek(6, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
    3347 fstat(6, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
    3347 write(6, "ptrace failed: Operation not per"..., 38) = 38
    3342 <... read resumed>"ptrace failed: Operation not per"..., 1000) = 38

    3347 exit_group(1 <unfinished ...>
    3342 wait4(3347, <unfinished ...>
    3347 <... exit_group resumed>) = ?
    3347 +++ exited with 1 +++
    3342 <... wait4 resumed>NULL, 0, NULL) = 3347
    3342 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3347, si_uid=1000, si_status=1, si_utime=0, si_stime=5} ---
    3342 close(5) = 0
    3342 write(7, "$E08#ad", 7 <unfinished ...>
    3337 <... select resumed>) = 1 (in [6], left {tv_sec=9, tv_usec=288501})
    3342 <... write resumed>) = 7
    3337 read(6, <unfinished ...>
    3342 gettid( <unfinished ...>
    3337 <... read resumed>"$E08#ad", 8192) = 7
    3342 <... gettid resumed>) = 3342
    3337 gettid( <unfinished ...>
    3342 select(8, [3 7], NULL, NULL, {tv_sec=0, tv_usec=0} <unfinished ...>
    3337 <... gettid resumed>) = 3337
    3342 <... select resumed>) = 0 (Timeout)
    3337 close(6 <unfinished ...>
    3342 rt_sigprocmask(SIG_SETMASK, NULL, <unfinished ...>
    3337 <... close resumed>) = 0
    3342 <... rt_sigprocmask resumed>[HUP], 8) = 0
    3337 close(8 <unfinished ...>
    3342 ppoll([{fd=7, events=POLLIN}], 1, NULL, [], 8 <unfinished ...>
    3337 <... close resumed>) = 0
    3342 <... ppoll resumed>) = 1 ([{fd=7, revents=POLLIN|POLLHUP}])
    3337 close(9 <unfinished ...>
    3342 select(8, [3 7], NULL, NULL, {tv_sec=0, tv_usec=0} <unfinished ...>
    3337 <... close resumed>) = 0
    3342 <... select resumed>) = 1 (in [7], left {tv_sec=0, tv_usec=0})
    3337 kill(3342, SIGINT <unfinished ...>
    3342 read(7, <unfinished ...>
    3337 <... kill resumed>) = 0
    3342 <... read resumed>"", 8192) = 0
    3337 write(2, "error: process launch failed: 'A"..., 62 <unfinished ...>
    3342 --- SIGINT {si_signo=SIGINT, si_code=SI_USER, si_pid=3337, si_uid=1000} ---

  25. zklim commented on Sep 14, 2022

    @zklim

    Unless I'm mistaken and am not on WSL2, this still seems to be an issue for me on lldb even with WSL2.

    error: 'proc' is not an existing command.
    (lldb) target create "./test"
    Current executable set to '/tmp/test' (x86_64).
    (lldb) run
    Process 7242 launched: '/tmp/test' (x86_64)
    Process 7242 exited with status = -1 (0xffffffff) lost connection
    

    However, gdb works as expected.

    same problem here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions