Bug 158149

Summary: [GTK] ASSERTION_FAILED: m_key != PTHREAD_KEYS_MAX when defining WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH
Product: WebKit Reporter: Sergio Villar Senin <svillar>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bugs-noreply, cgarcia, commit-queue
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Sergio Villar Senin 2016-05-27 01:49:14 PDT
Whenever WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH is defined in order to pause the web process it crashes. Looks like when WTF::sleep is called the threading system is not properly initialized.

I remember that we recently changed the order in which wk and the platform are initialized, perhaps it's related to that.

Now the backtrace:
ASSERTION FAILED: m_key != PTHREAD_KEYS_MAX
../../Source/WTF/wtf/ThreadIdentifierDataPthreads.cpp(65) : static WTF::ThreadIdentifier WTF::ThreadIdentifierData::identifier()
1   0x7fbc0d6b5cfb ~/projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(WTFCrash+0x1e) [0x7fbc0d6b5cfb]
2   0x7fbc0d7111aa ~/projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(_ZN3WTF20ThreadIdentifierData10identifierEv+0x3c) [0x7fbc0d7111aa]
3   0x7fbc0d70607e ~/projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(_ZN3WTF13currentThreadEv+0xd) [0x7fbc0d70607e]
4   0x7fbc0d6ca4d6 ~/projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(+0x21a74d6) [0x7fbc0d6ca4d6]
5   0x7fbc0d6cb990 ~/projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(+0x21a8990) [0x7fbc0d6cb990]
6   0x7fbc0d6ca655 ~/projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(+0x21a7655) [0x7fbc0d6ca655]
7   0x7fbc0d6ca70f ~/projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(_ZN3WTF10ParkingLot21parkConditionallyImplEPKvSt8functionIFbvEES3_IFvvEENSt6chrono10time_pointINS8_3_V212steady_clockENS8_8durationIlSt5ratioILl1ELl1000000000EEEEEE+0x2d) [0x7fbc0d6ca70f]
8   0x7fbc13a1f048 ~/projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37(_ZN3WTF10ParkingLot17parkConditionallyIZNS_13ConditionBase9waitUntilINS_4LockEEEbRT_NSt6chrono10time_pointINS7_3_V212steady_clockENS7_8durationIlSt5ratioILl1ELl1000000000EEEEEEEUlvE_ZNS3_IS4_EEbS6_SF_EUlvE0_EEbPKvOS5_OT0_SF_+0x6d) [0x7fbc13a1f048]
9   0x7fbc13a1dd42 ~/projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37(_ZN3WTF13ConditionBase9waitUntilINS_4LockEEEbRT_NSt6chrono10time_pointINS5_3_V212steady_clockENS5_8durationIlSt5ratioILl1ELl1000000000EEEEEE+0x6e) [0x7fbc13a1dd42]
10  0x7fbc13a1c5d3 ~/projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37(_ZN3WTF13ConditionBase11waitForImplINS_4LockENSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEEEEbRT_RKT0_+0x3d) [0x7fbc13a1c5d3]
11  0x7fbc13a1a2d7 ~/projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37(_ZN3WTF13ConditionBase18waitForSecondsImplINS_4LockEEEbRT_d+0xd1) [0x7fbc13a1a2d7]
12  0x7fbc0d6b8e5c ~/projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(_ZN3WTF13ConditionBase30waitUntilMonotonicClockSecondsINS_4LockEEEbRT_d+0x3a) [0x7fbc0d6b8e5c]
13  0x7fbc0d6b8df2 ~/projects/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(_ZN3WTF5sleepEd+0x56) [0x7fbc0d6b8df2]
14  0x7fbc138d6dac ~/projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37(_ZN6WebKit14WebProcessMain18platformInitializeEv+0x3a) [0x7fbc138d6dac]
15  0x7fbc138d6ebd ~/projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37(_ZN6WebKit16ChildProcessMainINS_10WebProcessENS_14WebProcessMainEEEiiPPc+0x28) [0x7fbc138d6ebd]
16  0x7fbc138d6d70 ~/projects/WebKit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37(WebProcessMainUnix+0x20) [0x7fbc138d6d70]
17  0x400bfa ~/projects/WebKit/WebKitBuild/Debug/bin/WebKitWebProcess(main+0x34) [0x400bfa]
18  0x7fbc0291e870 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7fbc0291e870]
19  0x400af9 ~/projects/WebKit/WebKitBuild/Debug/bin/WebKitWebProcess(_start+0x29) [0x400af9]
Comment 1 Carlos Garcia Campos 2016-05-27 01:55:57 PDT
Yes, this is what I tried to fix in #156622, WTF::sleep requires the threading to be initialized, but it's initlized after the sleep. Before WTF::sleep was added, we used the c sleep instead. I don't know how to disambiguate it. Maybe we could simply use g_usleep
Comment 2 Fujii Hironori 2016-07-01 01:07:18 PDT
Created attachment 282522 [details]
Patch
Comment 3 Carlos Garcia Campos 2016-07-01 06:23:17 PDT
Comment on attachment 282522 [details]
Patch

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

Thanks!

> Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp:52
> -            WTF::sleep(30);
> +            g_usleep(30 * 1000 * 1000);

Yes, this is what I do locally every time I need it, and then always forget to create a patch after the debugging. But please, use the  G_USEC_PER_SEC  macros instead of 1000 * 1000.
Comment 4 Carlos Garcia Campos 2016-07-01 06:24:00 PDT
*** Bug 156622 has been marked as a duplicate of this bug. ***
Comment 5 Fujii Hironori 2016-07-03 23:57:27 PDT
Created attachment 282684 [details]
Patch

Thank you for review. I created a new patch with Please. Could your review again?
Comment 6 Carlos Garcia Campos 2016-07-04 00:14:00 PDT
Comment on attachment 282684 [details]
Patch

Thanks!
Comment 7 WebKit Commit Bot 2016-07-04 00:35:34 PDT
Comment on attachment 282684 [details]
Patch

Clearing flags on attachment: 282684

Committed r202801: <http://trac.webkit.org/changeset/202801>
Comment 8 WebKit Commit Bot 2016-07-04 00:35:38 PDT
All reviewed patches have been landed.  Closing bug.