llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.62k stars 11.83k forks source link

lldb connection lost when using popen #113315

Open Hexlord opened 3 hours ago

Hexlord commented 3 hours ago

This code has 100% repro for connection lost with lldb that prevents debugging e.g. a game that uses popen to invoke shader compilation in real time. Tested on ubuntu 6.8.0-45-generic with lldb 17.0.6 and lldb 18.1.3

#include <memory>
#include <thread>
#include <vector>

void thread_func() {
    for(auto i = 0; i < 100; ++i) {
        auto pipe = popen("7z", "r");
        pclose(pipe);
        std::this_thread::sleep_for(std::chrono::milliseconds(100));
    }
}

int main() {

    std::vector<std::thread> threads;
    for(auto i = 0; i < 10; ++i) {
        threads.emplace_back(std::thread(thread_func));
    }
    for(auto &thread : threads) {
        thread.join();
    }
    return 0;
}

lldb.log

llvmbot commented 3 hours ago

@llvm/issue-subscribers-lldb

Author: Aleksandr Knorre (Hexlord)

This code has 100% repro for connection lost with lldb that prevents debugging e.g. a game that uses popen to invoke shader compilation in real time. Tested on ubuntu 6.8.0-45-generic with lldb 17.0.6 and lldb 18.1.3 ```c++ #include <memory> #include <thread> #include <vector> void thread_func() { for(auto i = 0; i < 100; ++i) { auto pipe = popen("7z", "r"); pclose(pipe); std::this_thread::sleep_for(std::chrono::milliseconds(100)); } } int main() { std::vector<std::thread> threads; for(auto i = 0; i < 10; ++i) { threads.emplace_back(std::thread(thread_func)); } for(auto &thread : threads) { thread.join(); } return 0; } ``` [lldb.log](https://github.com/user-attachments/files/17477143/lldb.log)