Bug 158073 - [Win] jsc.exe sometimes never exits.
Summary: [Win] jsc.exe sometimes never exits.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Per Arne Vollan
URL:
Keywords:
Depends on: 160096
Blocks:
  Show dependency treegraph
 
Reported: 2016-05-25 07:50 PDT by Per Arne Vollan
Modified: 2017-01-03 02:37 PST (History)
7 users (show)

See Also:


Attachments
Patch (2.50 KB, patch)
2016-05-25 08:09 PDT, Per Arne Vollan
no flags Details | Formatted Diff | Diff
Patch (1.53 KB, patch)
2016-07-22 06:07 PDT, Per Arne Vollan
no flags Details | Formatted Diff | Diff
Crash log (33.67 KB, application/octet-stream)
2016-07-22 13:25 PDT, Ryan Haddad
no flags Details
Patch (2.61 KB, patch)
2016-08-25 05:53 PDT, Per Arne Vollan
no flags Details | Formatted Diff | Diff
Patch (2.11 KB, patch)
2016-12-13 07:16 PST, Per Arne Vollan
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Per Arne Vollan 2016-05-25 07:50:37 PDT
Sometimes jsc.exe never exits. Debugging shows that is waits for a lock under MachineThreads::removeThreadIfFound when calling jscExit().
Comment 1 Per Arne Vollan 2016-05-25 08:09:24 PDT
Created attachment 279771 [details]
Patch
Comment 2 Darin Adler 2016-05-30 20:43:28 PDT
Comment on attachment 279771 [details]
Patch

Ideally I’d like to see a more elegant fix for this.

It’s really unfortunate to need the MainThread concept at all in this file; that’s a more fragile higher level concept than the rest of what is here. This should be a lower level class than MainThread. The need to initialize the main thread in jsc.cpp shows this new Windows-only dependency we are creating on the MainThread concept. Is there some Windows-specific way to understand which thread is the main one.

It also seems better to not pass the remove function to threadSpecificKeyCreate in the first place rather than adding the function but then having the function do nothing. So I would put the code in the MachineThreads constructor.
Comment 3 David Kilzer (:ddkilzer) 2016-06-21 11:29:41 PDT
Comment on attachment 279771 [details]
Patch

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

r=me

> Source/JavaScriptCore/jsc.cpp:2350
>      // Initialize JSC before getting VM.
> -#if ENABLE(SAMPLING_REGIONS)
> +#if ENABLE(SAMPLING_REGIONS) || OS(WINDOWS)
>      WTF::initializeMainThread();
>  #endif

Why is Windows the only OS that needs to call WTF::initializeMainThread()?

Is there some Windows-specific initialization that's needed, or does this get initialized in a different places on macOS/iOS?
Comment 4 Per Arne Vollan 2016-06-27 06:19:20 PDT
(In reply to comment #3)
> Comment on attachment 279771 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=279771&action=review
> 
> r=me
> 
> > Source/JavaScriptCore/jsc.cpp:2350
> >      // Initialize JSC before getting VM.
> > -#if ENABLE(SAMPLING_REGIONS)
> > +#if ENABLE(SAMPLING_REGIONS) || OS(WINDOWS)
> >      WTF::initializeMainThread();
> >  #endif
> 
> Why is Windows the only OS that needs to call WTF::initializeMainThread()?
> 
> Is there some Windows-specific initialization that's needed, or does this
> get initialized in a different places on macOS/iOS?

Thanks for reviewing!

I added this call, because the implementation on Windows of isMainThread() requires that WTF::initializeMainThread() is called first.
Comment 5 Per Arne Vollan 2016-06-27 06:33:32 PDT
(In reply to comment #2)
> Comment on attachment 279771 [details]
> Patch
> 
> Ideally I’d like to see a more elegant fix for this.
> 
> It’s really unfortunate to need the MainThread concept at all in this file;
> that’s a more fragile higher level concept than the rest of what is here.
> This should be a lower level class than MainThread. The need to initialize
> the main thread in jsc.cpp shows this new Windows-only dependency we are
> creating on the MainThread concept. Is there some Windows-specific way to
> understand which thread is the main one.
> 
> It also seems better to not pass the remove function to
> threadSpecificKeyCreate in the first place rather than adding the function
> but then having the function do nothing. So I would put the code in the
> MachineThreads constructor.

Thanks for reviewing :)

I also see that there is an additional difference in how the pthread and Windows thread specific implementation work. On Windows, the destructor is also called when threadSpecificKeyDelete is called, see https://msdn.microsoft.com/en-us/library/windows/desktop/ms682665(v=vs.85).aspx. This does not seem to be the case with the pthread implementation, as far as I can see. With this in mind, I think this patch needs a little more work.
Comment 6 Per Arne Vollan 2016-07-22 06:07:39 PDT
Created attachment 284328 [details]
Patch
Comment 7 Mark Lam 2016-07-22 10:17:56 PDT
Comment on attachment 284328 [details]
Patch

r=me
Comment 8 Per Arne Vollan 2016-07-22 11:05:13 PDT
(In reply to comment #7)
> Comment on attachment 284328 [details]
> Patch
> 
> r=me

Thanks for reviewing!
Comment 9 WebKit Commit Bot 2016-07-22 11:27:04 PDT
Comment on attachment 284328 [details]
Patch

Clearing flags on attachment: 284328

Committed r203603: <http://trac.webkit.org/changeset/203603>
Comment 10 WebKit Commit Bot 2016-07-22 11:27:10 PDT
All reviewed patches have been landed.  Closing bug.
Comment 11 Ryan Haddad 2016-07-22 13:25:30 PDT
Created attachment 284367 [details]
Crash log

This change seems to have caused CLoop tests to fail with this assertion:

mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(17) =  PASSED!
mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: ASSERTION FAILED: m_apiLock->currentThreadIsHoldingLock()
mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: /Volumes/Data/slave/elcapitan-cloop-debug/build/Source/JavaScriptCore/runtime/VM.cpp(364) : JSC::VM::~VM()
mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 1   0x103a9b0e0 WTFCrash
mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 2   0x103a43e55 JSC::VM::~VM()
mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 3   0x103a45025 JSC::VM::~VM()
mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 4   0x10328b6c9 WTF::ThreadSafeRefCounted<JSC::VM>::deref()
mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 5   0x10328b670 WTF::Ref<JSC::VM>::~Ref()
mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 6   0x10326dd35 WTF::Ref<JSC::VM>::~Ref()
mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 7   0x103260526 jscmain(int, char**)
mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 8   0x10326035b main
mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 9   0x7fff8f36c5ad start
mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 10  0x7


https://build.webkit.org/builders/Apple%20El%20Capitan%20LLINT%20CLoop%20%28BuildAndTest%29/builds/8242
Comment 12 WebKit Commit Bot 2016-07-22 13:30:38 PDT
Re-opened since this is blocked by bug 160096
Comment 13 Saam Barati 2016-07-22 13:41:15 PDT
(In reply to comment #11)
> Created attachment 284367 [details]
> Crash log
> 
> This change seems to have caused CLoop tests to fail with this assertion:
> 
> mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: x = new
> Function(); x.toString = Object.prototype.toString; x.charAt =
> String.prototype.charAt; x.charAt(17) =  PASSED!
> mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: ASSERTION
> FAILED: m_apiLock->currentThreadIsHoldingLock()
> mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint:
> /Volumes/Data/slave/elcapitan-cloop-debug/build/Source/JavaScriptCore/
> runtime/VM.cpp(364) : JSC::VM::~VM()
> mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 1   0x103a9b0e0
> WTFCrash
> mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 2   0x103a43e55
> JSC::VM::~VM()
> mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 3   0x103a45025
> JSC::VM::~VM()
> mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 4   0x10328b6c9
> WTF::ThreadSafeRefCounted<JSC::VM>::deref()
> mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 5   0x10328b670
> WTF::Ref<JSC::VM>::~Ref()
> mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 6   0x10326dd35
> WTF::Ref<JSC::VM>::~Ref()
> mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 7   0x103260526
> jscmain(int, char**)
> mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 8   0x10326035b
> main
> mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 9  
> 0x7fff8f36c5ad start
> mozilla-tests.yaml/ecma/String/15.5.4.4-4.js.mozilla-llint: 10  0x7
> 
> 
> https://build.webkit.org/builders/
> Apple%20El%20Capitan%20LLINT%20CLoop%20%28BuildAndTest%29/builds/8242

I think this change will cause every debug JSC stress test to fail.
Comment 14 Per Arne Vollan 2016-08-25 05:53:33 PDT
Created attachment 286962 [details]
Patch
Comment 15 Per Arne Vollan 2016-11-17 04:13:09 PST
This bug appears to be causing timeouts on Windows bots when running JSC stress tests.
Comment 16 Brent Fulgham 2016-11-17 09:33:23 PST
Comment on attachment 286962 [details]
Patch

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

> Source/JavaScriptCore/jsc.cpp:-2435
> -#if ENABLE(SAMPLING_REGIONS)

Did you mean to remove this for all ports? Should it maybe be "#if ENABLE(SAMPLING_REGIONS) || PLATFORM(WIN)"?
Comment 17 Per Arne Vollan 2016-11-18 07:15:05 PST
(In reply to comment #16)
> Comment on attachment 286962 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=286962&action=review
> 
> > Source/JavaScriptCore/jsc.cpp:-2435
> > -#if ENABLE(SAMPLING_REGIONS)
> 
> Did you mean to remove this for all ports? Should it maybe be "#if
> ENABLE(SAMPLING_REGIONS) || PLATFORM(WIN)"?

It seems this is the only place where ENABLE(SAMPLING_REGIONS) is still used, so I assumed it was not removed when the other occurrences of ENABLE(SAMPLING_REGIONS) were removed. But perhaps it should still be used here?
Comment 18 Per Arne Vollan 2016-12-13 07:16:05 PST
Created attachment 297012 [details]
Patch
Comment 19 Darin Adler 2016-12-22 09:52:24 PST
Comment on attachment 297012 [details]
Patch

This seems like an inelegant solution, but I don’t have something better to suggest at this time.
Comment 20 Per Arne Vollan 2017-01-03 02:35:15 PST
(In reply to comment #19)
> Comment on attachment 297012 [details]
> Patch
> 
> This seems like an inelegant solution, but I don’t have something better to
> suggest at this time.

Yes, I agree :) Thanks for reviewing!
Comment 21 Per Arne Vollan 2017-01-03 02:37:53 PST
Committed r210237: <http://trac.webkit.org/changeset/210237>