RESOLVED FIXED 242690
[WTF] Ensure isMainThread semantics for Linux match Apple/BSD semantics
https://bugs.webkit.org/show_bug.cgi?id=242690
Summary [WTF] Ensure isMainThread semantics for Linux match Apple/BSD semantics
James Hilliard
Reported 2022-07-13 07:49:31 PDT
It's not entirely clear if the current implementation semantics are fully identical between Linux and Apple/BSD systems. The Apple/BSD pthread_main_np function has 3 potential return values, 1 if the thread is the initial thread, 0 if it is not or -1 if thread is not initialized/unknown, lets make sure we only return true for isMainThread if the return for pthread_main_np is 1. On linux checking if we are on the initial thread can be accomplished by checking the equality of getpid and gettid. Note we use a syscall for calling gettid as the gettid() libc function may not be guaranteed to be supported by all libc's on Linux unlike the syscall(which is also used elsewhere in WebKit).
Attachments
James Hilliard
Comment 1 2022-07-13 07:53:49 PDT
EWS
Comment 2 2022-07-14 18:43:54 PDT
Committed 252485@main (50d7bfe855ca): <https://commits.webkit.org/252485@main> Reviewed commits have been landed. Closing PR #2363 and removing active labels.
Radar WebKit Bug Importer
Comment 3 2022-07-14 18:44:16 PDT
Adrian Perez
Comment 4 2022-07-19 00:36:42 PDT
Reopening to address Darin's comment about usage of pthread_main_np() here: https://github.com/WebKit/WebKit/commit/50d7bfe855ca043cc72ec09b3d3d75100015101b#r78597817
Adrian Perez
Comment 5 2022-07-19 00:49:21 PDT
EWS
Comment 6 2022-07-19 08:01:14 PDT
Committed 252601@main (0307ab9b687a): <https://commits.webkit.org/252601@main> Reviewed commits have been landed. Closing PR #2536 and removing active labels.
Michael Catanzaro
Comment 7 2022-08-01 09:39:29 PDT
Regression: bug #243401
Note You need to log in before you can comment on or make changes to this bug.