[Bug remote/33122] New: Packet error happens when using LD_RRELOAD+__attribute__((constructor))+std::thread+conditional_variable.wait

lleo at nvidia dot com sourceware-bugzilla@sourceware.org
Wed Jul 2 04:58:18 GMT 2025


https://sourceware.org/bugzilla/show_bug.cgi?id=33122

            Bug ID: 33122
           Summary: Packet error happens when using
                    LD_RRELOAD+__attribute__((constructor))+std::thread+co
                    nditional_variable.wait
           Product: gdb
           Version: 16.3
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: remote
          Assignee: unassigned at sourceware dot org
          Reporter: lleo at nvidia dot com
  Target Milestone: ---

Created attachment 16157
  --> https://sourceware.org/bugzilla/attachment.cgi?id=16157&action=edit
minimal reproducible example

I have a minimal reproducible example as the attachment, it's just a simple
shared library with codes like this:

```
#include <thread>
#include <mutex>
#include <condition_variable>

static std::thread t = std::thread([] {
    std::mutex m_mutex;
    std::unique_lock<std::mutex> lock(m_mutex);
    // It makes no sense to create local mutex and condition_variable here, but
this is just a demo
    printf("XXXX wait\n");
    std::condition_variable m_cv;
    m_cv.wait(lock, [=] {
        printf("XXXX check\n");
        return false;
    });
});
```
Let's call the shared library libMyTest.so, when I use it like this:
```
LD_PRELOAD=libMyTest.so gdbserver :1234 ./helloworld
```
The gdb client will report packet error and will lose the connection with
gdbserver eventually, for version 16.3, the logs are (with `set debug remote
1`):
client:
...
[remote] getpkt: Timed out.
Backtrace stopped: not enough registers or memory available to unwind further
...
server:
input_interrupt, count = 1 c = 36 ('$')
input_interrupt, count = 1 c = 36 ('$')
input_interrupt, count = 1 c = 36 ('$')
input_interrupt, count = 1 c = 36 ('$')
input_interrupt, count = 1 c = 36 ('$')
input_interrupt, count = 1 c = 36 ('$')
input_interrupt, count = 1 c = 36 ('$')
input_interrupt, count = 1 c = 36 ('$')

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Gdb-prs mailing list