Bug 242690 - [WTF] Ensure isMainThread semantics for Linux match Apple/BSD semantics
Summary: [WTF] Ensure isMainThread semantics for Linux match Apple/BSD semantics
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Adrian Perez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-07-13 07:49 PDT by James Hilliard
Modified: 2022-08-01 09:39 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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