Bug 239919

Summary: Add option to JSC shell to wait for a USR2 signal before exiting to aid in collection of vmmaps
Product: WebKit Reporter: Justin Michaud <justin_michaud>
Component: New BugsAssignee: Justin Michaud <justin_michaud>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cdumez, cmarcelo, ews-watchlist, keith_miller, mark.lam, msaboff, saam, tzagallo, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
ews-feeder: commit-queue-
Patch
none
Patch
none
Patch none

Description Justin Michaud 2022-04-29 17:29:06 PDT
Add option to JSC shell to wait for a USR2 signal before exiting to aid in collection of vmmaps
Comment 1 Justin Michaud 2022-04-29 17:30:16 PDT
Created attachment 458620 [details]
Patch
Comment 2 Justin Michaud 2022-04-29 17:31:22 PDT
Comment on attachment 458620 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=458620&action=review

> Source/WTF/wtf/threads/Signals.h:66
> +    case Signal::Usr: return std::make_tuple(SIGUSR2, std::nullopt);

Either I fixed a happy little bug, or I am about to feel the wrath of some deep horrible bug that this works around
Comment 3 Yusuke Suzuki 2022-04-29 17:42:26 PDT
Comment on attachment 458620 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=458620&action=review

r=me with comments.

> Source/JavaScriptCore/jsc.cpp:3041
> +    Lock waitToExitLock;
> +    Condition waitToExitCondition;
> +    bool mustWaitToExit = true;
> +

You can use WTF::BinarySemaphore instead.

> Source/JavaScriptCore/jsc.cpp:3049
> +            {
> +                Locker locker { waitToExitLock };
> +                mustWaitToExit = false;
> +                waitToExitCondition.notifyAll();
> +            }

Ditto.

> Source/JavaScriptCore/jsc.cpp:3078
> +        {
> +            Locker locker { waitToExitLock };
> +            while (mustWaitToExit)
> +                waitToExitCondition.wait(waitToExitLock);
> +        }
> +

Ditto.

>> Source/WTF/wtf/threads/Signals.h:66
>> +    case Signal::Usr: return std::make_tuple(SIGUSR2, std::nullopt);
> 
> Either I fixed a happy little bug, or I am about to feel the wrath of some deep horrible bug that this works around

Currently, Signal::Usr is not used. So yeah, it is a bug, but it will not affect on the existing code :)
Comment 4 Justin Michaud 2022-04-29 18:10:39 PDT
Created attachment 458622 [details]
Patch
Comment 5 Justin Michaud 2022-04-29 18:11:09 PDT
I'm going to land once EWS finishes.
Comment 6 Justin Michaud 2022-04-29 20:57:08 PDT
Created attachment 458627 [details]
Patch
Comment 7 EWS 2022-05-02 14:08:57 PDT
ChangeLog entry in Source/JavaScriptCore/ChangeLog contains OOPS!.
Comment 8 Justin Michaud 2022-05-02 14:19:08 PDT
Created attachment 458705 [details]
Patch
Comment 9 EWS 2022-05-02 15:35:04 PDT
Committed r293688 (250186@main): <https://commits.webkit.org/250186@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 458705 [details].
Comment 10 Radar WebKit Bug Importer 2022-05-02 15:36:13 PDT
<rdar://problem/92637189>