Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lldb-server crashes on Windows when debugger disconnects #56346

Open
jamal opened this issue Jul 1, 2022 · 8 comments · Fixed by #101283
Open

lldb-server crashes on Windows when debugger disconnects #56346

jamal opened this issue Jul 1, 2022 · 8 comments · Fixed by #101283

Comments

@jamal
Copy link

jamal commented Jul 1, 2022

lldb-server appears to crash on Windows as the remote debugger disconnects, causing me to have to restart it each time I run debug.

> .\lldb-server.exe platform --listen "*:1234" --server
Connection established.
error: lost connection
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.      Program arguments: C:\\Users\\WDKRemoteUser\\lldb-server.exe platform --listen *:1234 --server
1.      Program arguments: C:\\Users\\WDKRemoteUser\\lldb-server.exe platform --listen *:1234 --server
0x00007FF6415C1100 (0x000001B6A5F5BDA0 0x000000A4AF38FD28 0x0000000000000000 0x00007FFA66AF131E)
0x00007FF6415C71D3 (0x00007FF642638080 0x000000A4AF38FE40 0x000000A4AF38FE40 0x00007FFA71C912B0)
0x00007FF6415C8F84 (0x0000000000000000 0x00007FF64245EBED 0x0000000000000000 0x0000000000000000)
0x00007FF64245EB74 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000)
0x00007FFA737154E0 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), BaseThreadInitThunk() + 0x10 bytes(s)
0x00007FFA7468485B (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), RtlUserThreadStart() + 0x2B bytes(s)
@llvmbot
Copy link
Member

llvmbot commented Jul 1, 2022

@llvm/issue-subscribers-lldb

@LB767
Copy link

LB767 commented Nov 22, 2022

Apparently this is still an issue, is there any workaround?

slydiman added a commit to slydiman/llvm-project that referenced this issue Jul 25, 2024
…t mapping

Removed fork(). Used threads and the common thread-safe port map for all platform connections.

Updated lldb::FileSystem to use llvm::vfs::createPhysicalFileSystem() with an own virtual working directory per thread.

This patch depends on llvm#100659, llvm#100666.

This patch fixes llvm#97537, llvm#90923, llvm#56346.

lldb-server has been tested on Windows with 50 connections and 100 processes launched simultaneously. Tested also the cross build with Linux x86_64 host and Linux Aarch64 target.
slydiman added a commit to slydiman/llvm-project that referenced this issue Jul 31, 2024
…t on Windows

`lldb-server --server` works on Windows now w/o multithreading. The rest functionality remains unchanged.

Added also PipeWindows::WriteWithTimeout(), fixed PipeWindows::ReadWithTimeout() and missing initialization of  m_read_overlapped.hEvent in the constructor PipeWindows(lldb::pipe_t read, lldb::pipe_t write).

Fixes llvm#90923, fixes llvm#56346.

This is the part 1 of the replacement of llvm#100670.

In the part 2 I plan to switch `lldb-server gdbserver` to use --fd and listen a common gdb port for all gdbserver connections. Then we can remove gdb port mapping to fix llvm#97537.
slydiman added a commit to slydiman/llvm-project that referenced this issue Jul 31, 2024
…t on Windows

`lldb-server --server` works on Windows now w/o multithreading. The rest functionality remains unchanged.

Added also PipeWindows::WriteWithTimeout(), fixed PipeWindows::ReadWithTimeout() and missing initialization of  m_read_overlapped.hEvent in the constructor PipeWindows(lldb::pipe_t read, lldb::pipe_t write).

Fixes llvm#90923, fixes llvm#56346.

This is the part 1 of the replacement of llvm#100670.

In the part 2 I plan to switch `lldb-server gdbserver` to use --fd and listen a common gdb port for all gdbserver connections. Then we can remove gdb port mapping to fix llvm#97537.
slydiman added a commit to slydiman/llvm-project that referenced this issue Jul 31, 2024
…t on Windows

`lldb-server platform --server` works on Windows now w/o multithreading. The rest functionality remains unchanged.

Added also PipeWindows::WriteWithTimeout(), fixed PipeWindows::ReadWithTimeout() and missing initialization of  m_read_overlapped.hEvent in the constructor PipeWindows(lldb::pipe_t read, lldb::pipe_t write).

Fixes llvm#90923, fixes llvm#56346.

This is the part 1 of the replacement of llvm#100670.

In the part 2 I plan to switch `lldb-server gdbserver` to use `--fd` and listen a common gdb port for all gdbserver connections. Then we can remove gdb port mapping to fix llvm#97537.
slydiman added a commit to slydiman/llvm-project that referenced this issue Jul 31, 2024
…t on Windows

`lldb-server platform --server` works on Windows now w/o multithreading. The rest functionality remains unchanged.

Added also PipeWindows::WriteWithTimeout(), fixed PipeWindows::ReadWithTimeout() and missing initialization of  m_read_overlapped.hEvent in the constructor PipeWindows(lldb::pipe_t read, lldb::pipe_t write).

Fixes llvm#90923, fixes llvm#56346.

Depends on llvm#101326.

This is the part 1 of the replacement of llvm#100670.

In the part 2 I plan to switch `lldb-server gdbserver` to use `--fd` and listen a common gdb port for all gdbserver connections. Then we can remove gdb port mapping to fix llvm#97537.
slydiman added a commit to slydiman/llvm-project that referenced this issue Jul 31, 2024
…t on Windows

`lldb-server platform --server` works on Windows now w/o multithreading. The rest functionality remains unchanged.

Added also PipeWindows::WriteWithTimeout(), fixed PipeWindows::ReadWithTimeout() and missing initialization of  m_read_overlapped.hEvent in the constructor PipeWindows(lldb::pipe_t read, lldb::pipe_t write).

Fixes llvm#90923, fixes llvm#56346.

Depends on llvm#101326.

This is the part 1 of the replacement of llvm#100670.

In the part 2 I plan to switch `lldb-server gdbserver` to use `--fd` and listen a common gdb port for all gdbserver connections. Then we can remove gdb port mapping to fix llvm#97537.
slydiman added a commit to slydiman/llvm-project that referenced this issue Jul 31, 2024
…t on Windows

`lldb-server platform --server` works on Windows now w/o multithreading. The rest functionality remains unchanged.

Depends on llvm#101383.

Fixes llvm#90923, fixes llvm#56346.

This is the part 1 of the replacement of llvm#100670.

In the part 2 I plan to switch `lldb-server gdbserver` to use `--fd` and listen a common gdb port for all gdbserver connections. Then we can remove gdb port mapping to fix llvm#97537.
slydiman added a commit to slydiman/llvm-project that referenced this issue Aug 1, 2024
…t mapping

Removed fork(). Used threads and the common thread-safe port map for all platform connections.

Updated lldb::FileSystem to use llvm::vfs::createPhysicalFileSystem() with an own virtual working directory per thread.

This patch depends on llvm#100659, llvm#100666.

This patch fixes llvm#97537, llvm#90923, llvm#56346.

lldb-server has been tested on Windows with 50 connections and 100 processes launched simultaneously. Tested also the cross build with Linux x86_64 host and Linux Aarch64 target.
slydiman added a commit to slydiman/llvm-project that referenced this issue Aug 6, 2024
`lldb-server platform --server` works on Windows now w/o multithreading. The rest functionality remains unchanged.

Fixes llvm#90923, fixes llvm#56346.

This is the part 1 of the replacement of llvm#100670.

In the part 2 I plan to switch `lldb-server gdbserver` to use `--fd` and listen a common gdb port for all gdbserver connections. Then we can remove gdb port mapping to fix llvm#97537.
slydiman added a commit to slydiman/llvm-project that referenced this issue Aug 6, 2024
`lldb-server platform --server` works on Windows now w/o multithreading. The rest functionality remains unchanged.

Fixes llvm#90923, fixes llvm#56346.

This is the part 1 of the replacement of llvm#100670.

In the part 2 I plan to switch `lldb-server gdbserver` to use `--fd` and listen a common gdb port for all gdbserver connections. Then we can remove gdb port mapping to fix llvm#97537.
bwendling pushed a commit to bwendling/llvm-project that referenced this issue Aug 15, 2024
llvm#101283)

`lldb-server platform --server` works on Windows now w/o multithreading.
The rest functionality remains unchanged.

Fixes llvm#90923, fixes llvm#56346.

This is the part 1 of the replacement of llvm#100670.

In the part 2 I plan to switch `lldb-server gdbserver` to use `--fd` and
listen a common gdb port for all gdbserver connections. Then we can
remove gdb port mapping to fiх llvm#97537.
adrian-prantl pushed a commit to adrian-prantl/llvm-project that referenced this issue Oct 5, 2024
llvm#101283)

`lldb-server platform --server` works on Windows now w/o multithreading.
The rest functionality remains unchanged.

Fixes llvm#90923, fixes llvm#56346.

This is the part 1 of the replacement of llvm#100670.

In the part 2 I plan to switch `lldb-server gdbserver` to use `--fd` and
listen a common gdb port for all gdbserver connections. Then we can
remove gdb port mapping to fiх llvm#97537.

(cherry picked from commit 82ee31f)
adrian-prantl pushed a commit to adrian-prantl/llvm-project that referenced this issue Oct 11, 2024
llvm#101283)

`lldb-server platform --server` works on Windows now w/o multithreading.
The rest functionality remains unchanged.

Fixes llvm#90923, fixes llvm#56346.

This is the part 1 of the replacement of llvm#100670.

In the part 2 I plan to switch `lldb-server gdbserver` to use `--fd` and
listen a common gdb port for all gdbserver connections. Then we can
remove gdb port mapping to fiх llvm#97537.

(cherry picked from commit 82ee31f)
adrian-prantl pushed a commit to adrian-prantl/llvm-project that referenced this issue Oct 11, 2024
llvm#101283)

`lldb-server platform --server` works on Windows now w/o multithreading.
The rest functionality remains unchanged.

Fixes llvm#90923, fixes llvm#56346.

This is the part 1 of the replacement of llvm#100670.

In the part 2 I plan to switch `lldb-server gdbserver` to use `--fd` and
listen a common gdb port for all gdbserver connections. Then we can
remove gdb port mapping to fiх llvm#97537.

(cherry picked from commit 82ee31f)
adrian-prantl pushed a commit to adrian-prantl/llvm-project that referenced this issue Oct 11, 2024
llvm#101283)

`lldb-server platform --server` works on Windows now w/o multithreading.
The rest functionality remains unchanged.

Fixes llvm#90923, fixes llvm#56346.

This is the part 1 of the replacement of llvm#100670.

In the part 2 I plan to switch `lldb-server gdbserver` to use `--fd` and
listen a common gdb port for all gdbserver connections. Then we can
remove gdb port mapping to fiх llvm#97537.

(cherry picked from commit 82ee31f)
@jamal
Copy link
Author

jamal commented Oct 21, 2024

Hi, I just tested this with lldb-server 19.1.2 and it appears that this is still happening. Should this be resolved? As far as I could tell, the PR that fixed the issue was merged before 19.1.2 but I may have missed something.

PS C:\Users\User\Desktop> ./lldb-server p --server --listen *:12345
Connection established.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: C:\\Users\\User\\Desktop\\lldb-server.exe p --server --listen *:12345
Exception Code: 0x80000003
0x00007FF62A64257C, C:\Users\User\Desktop\lldb-server.exe(0x00007FF62A370000) + 0x2D257C byte(s)
0x00007FF62A642880, C:\Users\User\Desktop\lldb-server.exe(0x00007FF62A370000) + 0x2D2880 byte(s)
0x00007FF62AD28D94, C:\Users\User\Desktop\lldb-server.exe(0x00007FF62A370000) + 0x9B8D94 byte(s)
0x00007FFB87A9257D, C:\Windows\System32\KERNEL32.DLL(0x00007FFB87A80000) + 0x1257D byte(s), BaseThreadInitThunk() + 0x1D byte(s)
0x00007FFB88E8AF08, C:\Windows\SYSTEM32\ntdll.dll(0x00007FFB88E30000) + 0x5AF08 byte(s), RtlUserThreadStart() + 0x28 byte(s)
PS C:\Users\User\Desktop> .\lldb-server.exe v
lldb version 19.1.2

@slydiman
Copy link
Contributor

I have no idea why this issue is closed now. @labath asked to revert my changes in #104238 and I have removed this issue from the PR description. Feel free to reopen this ussue.

But this crash looks strange now. lldb-server p --server runs a child process to handle the connection. Even the child process crashed at disconnecting, the main server process must still work and be able to handle new connections.

Please provide detailed repro steps to investigate this issue.

@DavidSpickett DavidSpickett reopened this Oct 21, 2024
@jamal
Copy link
Author

jamal commented Oct 21, 2024

Sure thing! I am working on debugging an application in a Windows 11 VM running on Hyper-V (with a Windows 11 host if that matters).

First, create a new VM with Hyper-V using all default settings (simply select Windows 11 and it should automatically download the image). Once set up, copy lldb-server.exe to the VM. I relied on the enhanced session support to copy the file over (ctrl+c the file on the host, then ctrl+v in the guest). Then in a terminal, start it with ./lldb-server.exe p --server --listen *:12345.

Then, I tried to run an application using lldb from the host. I'm using VSCode with CodeLLDB configured (as documented here). It runs the following commands before launch:

platform select remote-windows
platform connect connect://[guest-ip]:12345
settings set target.inherit-env false

After launching, it immediately fails with an error that the remote disconnected the connection. On the guest, you'll see lldb-server has exited with the provided output.

@jamal
Copy link
Author

jamal commented Oct 21, 2024

I tried to run this manually to make sure there wasn't an issue with how CodeLLDB was triggering this and noticed that lldb-server is crashing as soon as lldb connects (after issuing the platfrom connect command).

@slydiman
Copy link
Contributor

slydiman commented Oct 22, 2024

I copied lldb-server.exe, lldb.exe, liblldb.dll and an executable a.exe to D:\test
Run lldb-server.exe p --server --listen *:12345
Run lldb.exe -O "platform select remote-windows" -O "platform connect connect://127.0.0.1:12345" -o "platform shell mkdir d:\test\work" -o "platform settings -w d:\test\work" -o "file d:\test\a.exe" -o "run" -o "exit"
and got the following output in the server console:

D:\test>lldb-server.exe p --server --listen *:12345
Connection established.
Disconnected.

and the following output in the secont console:

D:\test>lldb.exe -O "platform select remote-windows" -O "platform connect connect://127.0.0.1:12345" -o "platform shell mkdir d:\test\work" -o "platform settings -w d:\test\work" -o "file d:\test\a.exe" -o "run" -o "exit"
(lldb) platform select remote-windows 
  Platform: remote-windows 
 Connected: no 
      Host: Windows 6.2.0 
(lldb) platform connect connect://127.0.0.1:12345 
  Platform: remote-windows 
    Triple: x86_64-pc-windows-msvc 
OS Version: 6.2.0 (Windows NT 6.2.0) 
  Hostname: SOME_NAME
 Connected: yes 
WorkingDir: D:\test 
    Kernel: Windows NT 6.2.0 
      Host: Windows 6.2.0 
(lldb) platform shell mkdir d:\test\work 
error: command returned with status 1 
(lldb) platform settings -w d:\test\work 
(lldb) file d:\test\a.exe 
Current executable set to 'd:\test\a.exe' (x86_64). 
(lldb) (lldb) run 
Process 3972 launched: 'd:\test\a.exe' (x86_64) 
Process 3972 exited with status = 1 (0x00000001) 
(lldb) exit 
D:\test>

It seems we need a crash dump (+binaries and pdb) to investigte what is wrong.

@slydiman
Copy link
Contributor

Try to specify --gdbserver-port 12346 and be sure both ports (12345 and 12346) are opened in the firewall on the VM.

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