[Webkit-unassigned] [Bug 125305] Incorrect usage of ThreadingOnce class.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Dec 5 12:44:11 PST 2013


https://bugs.webkit.org/show_bug.cgi?id=125305





--- Comment #6 from peavo at outlook.com  2013-12-05 12:42:29 PST ---
(In reply to comment #5)
> (From update of attachment 218528 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=218528&action=review
> 
> I know you are basically reverting to the original code here, but I think the original code still allows multiple threads to initialize. (Geof, please correct me where I'm wrong).
> 
> We are very close to switching to VS2013, which will allow us to use "std::call_once", which might be a better cross-platform solution.
> 
> > Source/JavaScriptCore/dfg/DFGWorklist.cpp:287
> > +    if (!initializedGlobalWorklist) {
> 
> It seems like this should be done using the old "check->lock mutex->check again" construct.  It seems like this logic still gives us a chance for two threads to initialize the global wordlist.
> 
> Shouldn't it be something like (pseudocode below):
> 
> static mutex initializationMutex;
> 
> Worklist* initializeGlobalWOrklist()
> {
> #if USE(PTHREADS)
>     pthread_once(&initializeGlobalWorklistKeyOnce, initializeGlobalWorklistOnce);
>  #else
>     static bool initializedGlobalWorklist = false;
>     if (!initializedGlobalWorklist) {
>         ScopedLock locker(intializationMutex);
>         if (!initializedGlobalWorklist) {
>              initializeGlobalWOrklistOnce();
>              initializeGlobalWorklist = true;
>         }
>     }
> 
> > Source/WTF/wtf/CompilationThread.cpp:52
> > +    if (!initializedCompilationThreads) {
> 
> Ditto above. I think we can double-initialize with this logic.

I agree that there is a possibility for double-initialization with just using a static flag.
But isn't the pseudocode above equivalent to using a static global ThreadingOnce object?

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list