Bug 94636 - WTF Threading leaks kernel objects on platforms that use pthreads
Summary: WTF Threading leaks kernel objects on platforms that use pthreads
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Hahnenberg
Depends on:
Blocks: 94660
  Show dependency treegraph
Reported: 2012-08-21 14:27 PDT by Mark Hahnenberg
Modified: 2012-10-10 11:08 PDT (History)
4 users (show)

See Also:

Patch (10.79 KB, patch)
2012-08-21 14:47 PDT, Mark Hahnenberg
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Hahnenberg 2012-08-21 14:27:27 PDT
Creating lots of Web workers on Mac platforms leaks lots of Mach ports. Eventually, the process can exhaust its allocation of Mach ports from the kernel, which can then cause all sorts of badness, including the inability to allocate new virtual memory from the kernel. ThreadingPthreads.cpp and ThreadIdentifierDataPthreads.cpp need to be refactored so that we do not leak these kernel resources. I would assume that we also leak kernel resources on other pthreads platforms as well.
Comment 1 Mark Hahnenberg 2012-08-21 14:47:17 PDT
Created attachment 159772 [details]
Comment 2 Geoffrey Garen 2012-08-21 15:19:19 PDT
Comment on attachment 159772 [details]

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

r=me with some style comments.

> Source/WTF/wtf/ThreadingPthreads.cpp:169
> +static pthread_t unsafePthreadHandleForIdentifier(ThreadIdentifier id)

How about calling this "pthreadHandleForIdentifierWithLockAlreadyHeld".

> Source/WTF/wtf/ThreadingPthreads.cpp:219
> +void threadWasJoined(ThreadIdentifier threadID)

Let's just move this code into waitForThreadCompletion.

> Source/WTF/wtf/ThreadingPthreads.cpp:258
> +void unsafeThreadWasDetached(ThreadIdentifier threadID)

Let's inline this, since I don't like the "unsafe" prefix and inlining will solve that and avoid anyone calling this without the lock.

> Source/WTF/wtf/ThreadingPthreads.cpp:264
> +        delete state;

Let's use OwnPtr in the map instead.
Comment 3 Mark Hahnenberg 2012-08-21 16:15:59 PDT
Committed r126208: <http://trac.webkit.org/changeset/126208>
Comment 4 Mark Hahnenberg 2012-10-10 11:08:44 PDT