[valgrind] [Bug 380269] No multithreading in macOS Sierra (10.12)
https://bugs.kde.org/show_bug.cgi?id=380269 --- Comment #4 from Louis Brunner --- Created attachment 109303 --> https://bugs.kde.org/attachment.cgi?id=109303&action=edit Fix crash when using multithreading on Mac OS X >= 10.12 I have finally managed to fix the issue that made pthread SIGSEGV when starting a new thread. The issue was related to the TSD. In _pthread_body, an inline function called __pthread_add_thread is called, which locks a mutex using a os_unfair_lock_lock function from libplatform. These functions use the TSD while calling _os_lock_owner_get_self to retrieve the current the current MAC Thread using _os_tsd_get_direct(__TSD_MACH_THREAD_SELF). Looking at this last function will reveal a `__asm__("mov %%gs:%1, %0" : "=r" (ret) : "m" (*(void **)(slot * sizeof(void *;`, knowing that __TSD_MACH_THREAD_SELF is 3, that outputs the `mov %gs:0x18,%ecx` that was causing problems. Now, I don't know why GS_CONST is suddenly 0 instead of the TSD address, but I found that pthread keeps the latter in its pthread_t structure and that it conveniently gives us the offset in an internal structure passed to bsdthread_register by _pthread_bsdthread_init (4th argument). In syswrap-darwin.c, we already store a few arguments passed to bsdthread_register, so I added a new one, which is the offset of the TSD member in the pthread_t structure. While starting the new thread in pthread_hijack, we can then set the value of GS_CONST to self (current pthread_t address) + pthread_tsd_offset. The program then executes normally when using pthread and multithreading. Note that a lot of programs (including yours Alexandru) still crash or malfunction (mismanagement of signals, ...) once they start running. However these issues seem unrelated to this particular pthread problem. -- You are receiving this mail because: You are watching all bug changes.
[valgrind] [Bug 380269] No multithreading in macOS Sierra (10.12)
https://bugs.kde.org/show_bug.cgi?id=380269 --- Comment #3 from Alexandru Croitor --- Stack trace is ==75877== Invalid read of size 4 ==75877==at 0x1014B62B1: _pthread_wqthread (in /usr/lib/system/libsystem_pthread.dylib) ==75877==by 0x1014B607C: start_wqthread (in /usr/lib/system/libsystem_pthread.dylib) ==75877== Address 0x18 is not stack'd, malloc'd or (recently) free'd ==75877== ==75877== ==75877== Process terminating with default action of signal 11 (SIGSEGV) ==75877== Access not within mapped region at address 0x18 ==75877==at 0x1014B62B1: _pthread_wqthread (in /usr/lib/system/libsystem_pthread.dylib) ==75877==by 0x1014B607C: start_wqthread (in /usr/lib/system/libsystem_pthread.dylib) -- You are receiving this mail because: You are watching all bug changes.
[valgrind] [Bug 380269] No multithreading in macOS Sierra (10.12)
https://bugs.kde.org/show_bug.cgi?id=380269 --- Comment #2 from Alexandru Croitor --- Created attachment 109082 --> https://bugs.kde.org/attachment.cgi?id=109082&action=edit Minimal test case -- You are receiving this mail because: You are watching all bug changes.
[valgrind] [Bug 380269] No multithreading in macOS Sierra (10.12)
https://bugs.kde.org/show_bug.cgi?id=380269 Alexandru Croitor changed: What|Removed |Added CC||alexandru.croi...@qt.io --- Comment #1 from Alexandru Croitor --- I encountered, and reproduced the same issue I believe, with a slightly different stack trace, after applying the provided patch in https://bugs.kde.org/show_bug.cgi?id=383723 . Attaching the minimal example to this issue as well. -- You are receiving this mail because: You are watching all bug changes.
[valgrind] [Bug 380269] No multithreading in macOS Sierra (10.12)
https://bugs.kde.org/show_bug.cgi?id=380269 Rhys Kidd changed: What|Removed |Added Ever confirmed|0 |1 Status|UNCONFIRMED |CONFIRMED CC||rhysk...@gmail.com Assignee|jsew...@acm.org |rhysk...@gmail.com Version|3.12 SVN|3.13 SVN -- You are receiving this mail because: You are watching all bug changes.
[valgrind] [Bug 380269] No multithreading in macOS Sierra (10.12)
https://bugs.kde.org/show_bug.cgi?id=380269 MrCraftCod changed: What|Removed |Added CC||zerd...@gmail.com -- You are receiving this mail because: You are watching all bug changes.
[valgrind] [Bug 380269] No multithreading in macOS Sierra (10.12)
https://bugs.kde.org/show_bug.cgi?id=380269 Louis Brunner changed: What|Removed |Added Blocks||365327 CC||louis.brunner...@gmail.com Referenced Bugs: https://bugs.kde.org/show_bug.cgi?id=365327 [Bug 365327] Support macOS Sierra (10.12) -- You are receiving this mail because: You are watching all bug changes.