Bug 242690

Summary: [WTF] Ensure isMainThread semantics for Linux match Apple/BSD semantics
Product: WebKit Reporter: James Hilliard <james.hilliard1>
Component: Web Template FrameworkAssignee: Adrian Perez <aperez>
Status: RESOLVED FIXED    
Severity: Normal CC: aperez, mcatanzaro, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=243401

Description James Hilliard 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).
Comment 1 James Hilliard 2022-07-13 07:53:49 PDT
Pull request: https://github.com/WebKit/WebKit/pull/2363
Comment 2 EWS 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.
Comment 3 Radar WebKit Bug Importer 2022-07-14 18:44:16 PDT
<rdar://problem/97048055>
Comment 4 Adrian Perez 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
Comment 5 Adrian Perez 2022-07-19 00:49:21 PDT
Pull request: https://github.com/WebKit/WebKit/pull/2536
Comment 6 EWS 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.
Comment 7 Michael Catanzaro 2022-08-01 09:39:29 PDT
Regression: bug #243401