summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qfutureinterface.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-04-29 08:27:27 -0700
committerThiago Macieira <thiago.macieira@intel.com>2022-04-29 18:33:38 -0700
commit1808df9ce59a8c1d426f0361e25120a7852a6442 (patch)
tree76a6d6fdcc8ff2342e8d3b7c66fc1da4f90863c8 /src/corelib/thread/qfutureinterface.cpp
parentb6759ff81c1b6ecb7e18144db0b7c9c5884d7f24 (diff)
QThread: Fix currentThreadId() on FreeBSD
We were reading from the wrong offset. It just happened to work on Linux because the values stored in the first and third fields of tcbhead_t[1] are the same. But that is not the case on FreeBSD for the same thing[2]. Confirmed by disassembly. Linux: Dump of assembler code for function __GI___pthread_self: 0x00007ffff71b6efe <+0>: endbr64 0x00007ffff71b6f02 <+4>: nop 0x00007ffff71b6f03 <+5>: nop 0x00007ffff71b6f04 <+6>: mov %fs:0x10,%rax 0x00007ffff71b6f0d <+15>: ret FreeBSD: (gdb) disass pthread_self Dump of assembler code for function _Tthr_self: 0x0000000800324790 <+0>: push %rbp 0x0000000800324791 <+1>: mov %rsp,%rbp 0x0000000800324794 <+4>: cmpq $0x0,0x8b1c(%rip) # 0x80032d2b8 <_thr_initial> 0x000000080032479c <+12>: jne 0x8003247a5 <_Tthr_self+21> 0x000000080032479e <+14>: xor %edi,%edi 0x00000008003247a0 <+16>: call 0x80031de40 <_libpthread_init> 0x00000008003247a5 <+21>: mov %fs:0x10,%rax 0x00000008003247ae <+30>: pop %rbp 0x00000008003247af <+31>: ret Also confirmed not to affect macOS: (lldb) disass -n pthread_self libsystem_pthread.dylib`pthread_self: libsystem_pthread.dylib[0x7ff80032186c] <+0>: pushq %rbp libsystem_pthread.dylib[0x7ff80032186d] <+1>: movq %rsp, %rbp libsystem_pthread.dylib[0x7ff800321870] <+4>: movq %gs:0x0, %rax [1] https://code.woboq.org/userspace/glibc/sysdeps/x86_64/nptl/tls.h.html#tcbhead_t [2] https://github.com/freebsd/freebsd-src/blob/main/sys/x86/include/tls.h#L43 Pick-to: 6.2 6.3 Fixes: QTBUG-103000 Change-Id: I7fb65b80b7844c8d8f26fffd16ea67d2f3461964 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/thread/qfutureinterface.cpp')
0 files changed, 0 insertions, 0 deletions