Go to file
Thiago Macieira 1808df9ce5 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>
2022-04-29 18:33:38 -07:00
.github/workflows Repair github action workflow 2021-11-10 18:57:33 +01:00
bin Provide a qtpaths wrapper script when cross-building Qt 2021-11-08 13:41:03 +01:00
cmake Pass compilers on to examples configs 2022-04-26 22:58:56 +02:00
coin CI: add Windows host support for QNX 2022-04-05 17:03:40 +03:00
config.tests CMake: Make sure the strip_for_binary project works with Makefiles 2022-04-04 15:41:20 +02:00
dist Add Qt 6.0.0 changes file 2020-11-16 10:02:08 +02:00
doc Doc: Fix typo in the HTML tabs config 2022-04-25 10:07:05 +02:00
examples Replace uses of _qs with _s in sources and examples 2022-04-19 19:12:20 +02:00
lib Purge all fonts 2015-08-18 19:59:14 +00:00
libexec CMake: Pass -v to ninja when using ctest --build-and-test 2022-04-04 15:41:20 +02:00
mkspecs wasm: add specialHTMLTargets to EXPORTED_RUNTIME_METHODS for qmake 2022-04-21 13:00:57 +10:00
qmake Replace uses of _qs with _s in sources and examples 2022-04-19 19:12:20 +02:00
src QThread: Fix currentThreadId() on FreeBSD 2022-04-29 18:33:38 -07:00
tests tst_QNetworkReply try stabilize autoDeleteReplies tests 2022-04-29 04:28:56 +00:00
util Generalize exclusion list 2022-04-22 15:39:03 +02:00
.cmake.conf cmake: only use qtbase configuration in qtbase 2022-03-18 12:33:10 +01:00
.gitattributes Give batch files CRLF line endings 2020-11-04 15:02:29 +00:00
.gitignore Assume qhelpgenerator in libexec instead of bin 2021-11-08 19:27:32 +01:00
.lgtm.yml Skip LGTM analysis for the bootstrap library and tools 2020-07-16 01:04:34 +02:00
.tag Update the git-archive export options 2012-09-07 15:39:31 +02:00
CMakeLists.txt Use REALPATH based check for symbolic links on Windows 2022-01-07 14:31:38 +01:00
conanfile.py Conan: Resolve the 'qt_host_path' before assigning it to 'QT_HOST_PATH' env 2022-04-06 17:46:59 +03:00
config_help.txt Build system: Allow user to enable Intel CET 2022-04-06 13:06:24 +08:00
configure Remove unsupported, host-related options from configure shell script 2021-08-05 02:44:27 +02:00
configure.bat configure.bat: Fix call without arguments 2022-02-16 12:05:48 +01:00
configure.cmake zlib as static library 2022-04-22 14:34:47 +02:00
dependencies.yaml Re-add dependencies.yaml now that qt5.git wip/qt6 builds fine 2019-09-18 13:19:31 +02:00
LICENSE.FDL Remove trailing whitespace in LICENSE.FDL 2021-11-26 18:28:49 +01:00
LICENSE.GPL2 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.GPL3 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.GPL3-EXCEPT Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.LGPL3 Add new license header templates and license files 2016-01-14 20:43:46 +00:00
LICENSE.QT-LICENSE-AGREEMENT Update LA 4.4.1 2022-03-25 20:07:30 +00:00
qt_cmdline.cmake Build system: Allow user to enable Intel CET 2022-04-06 13:06:24 +08:00
sync.profile QVariant: reduce transitive includes 2022-03-17 16:14:38 +00:00