You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That call doesn't appear at all in the shadow strace log, so I think it happens before shadow gets control.
Looking at the glibc source, I don't see the call to set_tid_address in _dl_deallocate_tls, and I'm not sure why thread local storage would be getting deallocated during early initialization.
Searching glibc for set_tid_address though, it does look like it gets called during tls initialization in __tls_init_tp, and stashed away in the thread control block.
My best guess is that the pthread internals later see this stashed native thread ID when looking at data about the main thread.
Possible fixes:
Get control earlier, before set_tid_address is called. This would probably involve a major architectural change, along the lines of what we'd need do to work without LD_PRELOAD (Running 100% statically linked executables #1839).
Get hold of the thread control block and overwrite the stashed tid. This is potentially less work, but also potentially fragile.
I don't see any earlier syscalls where it might have gotten hold of the native thread ID under shadow. There's a set_tid_address, which returns the tid, but shadow correctly intercepts that and returns the emulated thread id.
In rust programs, examining the strace log shows calls to
sched_getaffinitywith the native thread ID.Executing a rust program natively with
strace -kto get a full stack trace, we see something like:Earlier in the native strace we can see a call to
set_tid_address, which returns the tid:That call doesn't appear at all in the shadow strace log, so I think it happens before shadow gets control.
Looking at the glibc source, I don't see the call to
set_tid_addressin_dl_deallocate_tls, and I'm not sure why thread local storage would be getting deallocated during early initialization.Searching glibc for
set_tid_addressthough, it does look like it gets called during tls initialization in__tls_init_tp, and stashed away in the thread control block.My best guess is that the pthread internals later see this stashed native thread ID when looking at data about the main thread.
Possible fixes:
set_tid_addressis called. This would probably involve a major architectural change, along the lines of what we'd need do to work without LD_PRELOAD (Running 100% statically linked executables #1839).I don't see any earlier syscalls where it might have gotten hold of the native thread ID under shadow. There's a
set_tid_address, which returns the tid, but shadow correctly intercepts that and returns the emulated thread id.