Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Unable to attach, detach, and attach to the same PID. The second attach command fails. #36172

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR37199
Status NEW
Importance P enhancement
Reported by mewbaz@gmail.com
Reported on 2018-04-22 13:03:45 -0700
Last modified on 2018-04-22 13:06:02 -0700
Version 6.0
Hardware PC Linux
CC llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Problem description:
It is possible to attach to a process, detach from that process, but upon a
subsequent attempt to attach to the same process (after detaching), the attach
command fails, with "error: no error returned from Target::Attach, and target
has no process".

u@x220 ~> lldb --version
lldb version 6.0.0

u@x220 ~> sudo lldb
(lldb) attach 9594
Process 9594 stopped
* thread #1, name = 'target', stop reason = signal SIGSTOP
    frame #0: 0x00007f11ca4ccb10 libc.so.6`__GI___nanosleep + 64
libc.so.6`__GI___nanosleep:
->  0x7f11ca4ccb10 <+64>: cmpq   $-0x1000, %rax            ; imm = 0xF000
    0x7f11ca4ccb16 <+70>: ja     0x7f11ca4ccb42            ; <+114>
    0x7f11ca4ccb18 <+72>: movl   %edx, %edi
    0x7f11ca4ccb1a <+74>: movl   %eax, 0xc(%rsp)
  thread #2, name = 'target', stop reason = signal SIGSTOP
    frame #0: 0x00007f11ca4ccb10 libc.so.6`__GI___nanosleep + 64
libc.so.6`__GI___nanosleep:
->  0x7f11ca4ccb10 <+64>: cmpq   $-0x1000, %rax            ; imm = 0xF000
    0x7f11ca4ccb16 <+70>: ja     0x7f11ca4ccb42            ; <+114>
    0x7f11ca4ccb18 <+72>: movl   %edx, %edi
    0x7f11ca4ccb1a <+74>: movl   %eax, 0xc(%rsp)

Executable module set to "/home/u/Desktop/ptrace-call-userspace/target".
Architecture set to: x86_64-pc-linux.
(lldb) c
Process 9594 resuming
(lldb) detach
Process 9594 detached
(lldb) attach 9594
error: no error returned from Target::Attach, and target has no process
Quuxplusone commented 6 years ago

The program being debugged a simple threaded program repeatedly printing it's PID in two different threads.

https://gist.githubusercontent.com/mewmew/ace7ed6c545ab8390060c0355636b115/raw/78abf01d8d8a6d96d9b0b8ea39e6560458dc3dd4/target.c