Skip to content

[lldb] lldb-server may crash in the child process monitor thread #101475

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

Open
slydiman opened this issue Aug 1, 2024 · 1 comment
Open

[lldb] lldb-server may crash in the child process monitor thread #101475

slydiman opened this issue Aug 1, 2024 · 1 comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] lldb

Comments

@slydiman
Copy link
Contributor

slydiman commented Aug 1, 2024

Host::LaunchProcess() requires to SetMonitorProcessCallback. This callback is called from the child process monitor thread. We cannot control this thread anyway. GDBRemoteCommunicationServerPlatform::DebugserverProcessReaped() may cause a crash if this callback will be called from the child monitor thread after destroing the instance of GDBRemoteCommunicationServerPlatform.

void GDBRemoteCommunicationServerPlatform::DebugserverProcessReaped(
lldb::pid_t pid) {
std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex);
m_port_map.FreePortForProcess(pid);
m_spawned_pids.erase(pid);
}

And m_port_map requires an own mutex guard here.

@slydiman slydiman added the lldb label Aug 1, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 1, 2024

@llvm/issue-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)

Host::LaunchProcess() requires to SetMonitorProcessCallback. This callback is called from the child process monitor thread. We cannot control this thread anyway. GDBRemoteCommunicationServerPlatform::DebugserverProcessReaped() may cause a crash if this callback will be called from the child monitor thread after destroing the instance of GDBRemoteCommunicationServerPlatform.

void GDBRemoteCommunicationServerPlatform::DebugserverProcessReaped(
lldb::pid_t pid) {
std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex);
m_port_map.FreePortForProcess(pid);
m_spawned_pids.erase(pid);
}

And m_port_map requires an own mutex guard here.

@firewave firewave added the crash Prefer [crash-on-valid] or [crash-on-invalid] label Aug 1, 2024
slydiman added a commit to slydiman/llvm-project that referenced this issue Aug 14, 2024
Listen to gdbserver-port, accept the connection and run `lldb-server gdbserver --fd` on all platforms.
Added acceptor_gdb and gdb_thread to lldb-platform.cpp
SharedSocket has been moved to ConnectionFileDescriptorPosix.

Parameters --min-gdbserver-port and --max-gdbserver-port are deprecated now.

This is the part 2 of llvm#101283.

Fixes llvm#97537, fixes llvm#101475.
slydiman added a commit to slydiman/llvm-project that referenced this issue Aug 16, 2024
Listen to gdbserver-port, accept the connection and run `lldb-server gdbserver --fd` on all platforms.
Added acceptor_gdb and gdb_thread to lldb-platform.cpp
SharedSocket has been moved to ConnectionFileDescriptorPosix.

Parameters --min-gdbserver-port and --max-gdbserver-port are deprecated now.

This is the part 2 of llvm#101283.

Fixes llvm#97537, fixes llvm#101475.
slydiman added a commit to slydiman/llvm-project that referenced this issue Aug 26, 2024
Listen to gdbserver-port, accept the connection and run lldb-server gdbserver --fd on all platforms.
Refactored Acceptor to listen on 2 ports in the main thread.

Parameters --min-gdbserver-port and --max-gdbserver-port are deprecated now.

This is the part 2 of llvm#101283.

Fixes llvm#97537, fixes llvm#101475.
slydiman added a commit to slydiman/llvm-project that referenced this issue Aug 30, 2024
Listen to gdbserver-port, accept the connection and run lldb-server gdbserver --fd on all platforms.
Refactored Acceptor to listen on 2 ports in the main thread.

Parameters --min-gdbserver-port and --max-gdbserver-port are deprecated now.

This is the part 2 of llvm#101283.

Fixes llvm#97537, fixes llvm#101475.
slydiman added a commit to slydiman/llvm-project that referenced this issue Aug 30, 2024
Listen to gdbserver-port, accept the connection and run lldb-server gdbserver --fd on all platforms.
Refactored Acceptor to listen on 2 ports in the main thread.

Parameters --min-gdbserver-port and --max-gdbserver-port are deprecated now.

This is the part 2 of llvm#101283.

Fixes llvm#97537, fixes llvm#101475.
slydiman added a commit to slydiman/llvm-project that referenced this issue Sep 3, 2024
Listen to gdbserver-port, accept the connection and run lldb-server gdbserver --fd on all platforms.
Parameters --min-gdbserver-port and --max-gdbserver-port are deprecated now.

This is the part 2 of llvm#101283. Depends on llvm#106955.

Fixes llvm#97537, fixes llvm#101475.
slydiman added a commit to slydiman/llvm-project that referenced this issue Sep 3, 2024
Listen to gdbserver-port, accept the connection and run lldb-server gdbserver --fd on all platforms.
Parameters --min-gdbserver-port and --max-gdbserver-port are deprecated now.

This is the part 2 of llvm#101283.

Fixes llvm#97537, fixes llvm#101475.
slydiman added a commit to slydiman/llvm-project that referenced this issue Sep 6, 2024
Listen to gdbserver-port, accept the connection and run lldb-server gdbserver --fd on all platforms.
Parameters --min-gdbserver-port and --max-gdbserver-port are deprecated now.

This is the part 2 of llvm#101283.

Fixes llvm#97537, fixes llvm#101475.
slydiman added a commit to slydiman/llvm-project that referenced this issue Sep 6, 2024
Listen to gdbserver-port, accept the connection and run lldb-server gdbserver --fd on all platforms.
Parameters --min-gdbserver-port and --max-gdbserver-port are deprecated now.

This is the part 2 of llvm#101283.

Fixes llvm#97537, fixes llvm#101475.
slydiman added a commit to slydiman/llvm-project that referenced this issue Sep 13, 2024
Listen to gdbserver-port, accept the connection and run lldb-server gdbserver --fd on all platforms.
Parameters --min-gdbserver-port and --max-gdbserver-port are deprecated now.

This is the part 2 of llvm#101283.

Fixes llvm#97537, fixes llvm#101475.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] lldb
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants