[Webkit-unassigned] [Bug 55728] [fileapi] Worker File API calls that create Blobs fail in debug builds due to random number generator thread assertion

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue May 3 17:59:03 PDT 2011


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





--- Comment #18 from Michael Nordman <michaeln at google.com>  2011-05-03 17:59:03 PST ---
(In reply to comment #17)
> > Can you provide a pointer of the file/class/method that is causing the the problem?
> 
> Source/JavaScriptCore/wtf/FastMalloc.cpp:110
> 
> #if ENABLE(WTF_MULTIPLE_THREADS)
> static pthread_key_t isForbiddenKey;
> static pthread_once_t isForbiddenKeyOnce = PTHREAD_ONCE_INIT;
> static void initializeIsForbiddenKey()
> {
>   pthread_key_create(&isForbiddenKey, 0);
> }
> ...

Geez... that's a scary and hairy looking .cpp file.

There are a handful of places where pthread_once is used on JavaScriptCore. Most of them have OS(DARWIN) gaurds around them and some of them also have a not-so-thread-safe impl if not OS(DARWIN). JSLock in the absence of PTHREADS is scary... but it looks like the only pthreads callsite that matters for V8 users FastMalloc.

The callsite in FastMalloc only matters for DEBUG builds (which is not obvious when looking at the .cpp file). This should be implementable in terms of TlsAlloc(), TlsGetValue(), and TlsSetValue() on windows.


#include <windows.h>

static DWORD isForibiddenTlsIndex = TLS_OUT_OF_INDEXES;

static bool isForbidden()
{
    // By default, fastMalloc is allowed so we don't allocate the
    // tls index unless we're asked to make it forbidden.
    return (isForibiddenTlsIndex != TLS_OUT_OF_INDEXES)
           && (TlsGetValue(isForibiddenTlsIndex) == (LPVOID)1);
}

void fastMallocForbid()
{
    if (isForibiddenTlsIndex == TLS_OUT_OF_INDEXES)
        isForibiddenTlsIndex = TlsAlloc();  // a little racey, but close enough for debug only
    TlsSetValue(isForibiddenTlsIndex, (LPVOID)1);
}

void fastMallocAllow()
{
    if (isForibiddenTlsIndex == TLS_OUT_OF_INDEXES)
        return;
    TlsSetValue(isForibiddenTlsIndex, (LPVOID)0);
}

-- 
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