Bug 141209 - Workaround a thread library bug where thread destructors may not get called
Summary: Workaround a thread library bug where thread destructors may not get called
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Lam
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-02-03 13:48 PST by Mark Lam
Modified: 2015-02-03 16:01 PST (History)
6 users (show)

See Also:


Attachments
the patch (6.01 KB, patch)
2015-02-03 14:02 PST, Mark Lam
msaboff: review-
Details | Formatted Diff | Diff
patch 2: no more race condition. (8.80 KB, patch)
2015-02-03 15:36 PST, Mark Lam
msaboff: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Lam 2015-02-03 13:48:53 PST
As far as we know, there's a darwin bug where thread destructors may not get called.  We will work around this by checking at GC time if the platform thread is still valid.  If not, we'll purge it from the VM's registeredThreads list before proceeding with thread scanning activity.
Comment 1 Mark Lam 2015-02-03 13:51:37 PST
<rdar://problem/17979784>
Comment 2 Mark Lam 2015-02-03 14:02:04 PST
Created attachment 245965 [details]
the patch
Comment 3 Alexey Proskuryakov 2015-02-03 14:17:42 PST
> there's a darwin bug

Is there a Radar tracking that?
Comment 4 Michael Saboff 2015-02-03 14:29:58 PST
Comment on attachment 245965 [details]
the patch

r-
I believe that there is a race condition.  Consider thread A is exiting and it has already called MachineThreads::removeThread() but hasn't really exited.  Then thread B executes this code and doesn't purge thread A.  After completing this code, thread A really exits and then we call tryCopyOtherThreadStacks().  We'll still try to get thread stack info from the now dead A.
Comment 5 Mark Lam 2015-02-03 15:36:21 PST
Created attachment 245977 [details]
patch 2: no more race condition.
Comment 6 Michael Saboff 2015-02-03 15:48:42 PST
Comment on attachment 245977 [details]
patch 2: no more race condition.

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

r=me with a couple of minor changes.

> Source/JavaScriptCore/ChangeLog:15
> +        suspension, because the thread is only guaranteed to be alive while it

Might want to change "the thread" to "another thread".

> Source/JavaScriptCore/heap/MachineStackMarker.cpp:194
> +void MachineThreads::removeThreadWithLockAlreadyAcquired(PlatformThread platformThread)

threadToRemove seems like a better name for the argument.
Comment 7 Mark Lam 2015-02-03 15:55:43 PST
(In reply to comment #6)
> Comment on attachment 245977 [details]
> patch 2: no more race condition.
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=245977&action=review
> 
> r=me with a couple of minor changes.
> 
> > Source/JavaScriptCore/ChangeLog:15
> > +        suspension, because the thread is only guaranteed to be alive while it
> 
> Might want to change "the thread" to "another thread".

Will change the wording to me more clear that it the another thread whose validity we're checking.

> > Source/JavaScriptCore/heap/MachineStackMarker.cpp:194
> > +void MachineThreads::removeThreadWithLockAlreadyAcquired(PlatformThread platformThread)
> 
> threadToRemove seems like a better name for the argument.

Changed.
Comment 8 Mark Lam 2015-02-03 16:01:04 PST
Thanks for the review.  Landed in r179576: <http://trac.webkit.org/r179576>.