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

aburgess at redhat dot com sourceware-bugzilla@sourceware.org
Tue Jul 8 12:17:52 GMT 2025


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

Andrew Burgess <aburgess at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aburgess at redhat dot com
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2025-07-08
     Ever confirmed|0                           |1

--- Comment #2 from Andrew Burgess <aburgess at redhat dot com> ---
Assuming the goal here is to preload the library into the inferior itself, not
gdbserver, then I wonder if gdbserver should gain some new command line flags?
These flags could appear multiple times on the gdbserver command line, and
would be processed left to right, updating the inferior's environment as they
go:

  --env-clear --- clear the environment back to empty,
  --env-set=VAR=VAL --- Set VAR=VAL in the inferior's environment, and
  --env-unset=VAR --- Unset VAR from the inferior's environment.

So now you could:

  gdbserver --env-set=LD_PRELOAD=libMyTest.so :1234 ./helloworld

And this wouldn't preload the library into gdbserver.

Until then, you can work around this problem by injecting the new environment
from the GDB side.  Start gdbserver like this:

  $ gdbserver --multi :54321 ./helloworld

Then in GDB:

  $ gdb
  (gdb) target extended-remote :54321
  (gdb) set environment LD_PRELOAD=/path/to/libMyTest.so
  (gdb) run

This isnt ideal, but should do what you need.

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


More information about the Gdb-prs mailing list