Bug 51860

Summary: LEAK: Deallocate instance of ThreadFunctionInvocation if thread creation fails
Product: WebKit Reporter: Daniel Bates <dbates>
Component: Web Template FrameworkAssignee: Daniel Bates <dbates>
Status: RESOLVED FIXED    
Severity: Normal CC: aroben, eric
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Windows XP   
Attachments:
Description Flags
Patch
none
Patch
none
Patch aroben: review+

Description Daniel Bates 2011-01-03 18:06:17 PST
If either CreateThread() or _beginthreadex() fails then we should deallocate the instance of ThreadFunctionInvocation we created.
Comment 1 Daniel Bates 2011-01-03 18:08:01 PST
Created attachment 77857 [details]
Patch
Comment 2 Eric Seidel (no email) 2011-01-03 23:44:44 PST
Don't we have a cleaner way to do this?
Comment 3 Daniel Bates 2011-01-03 23:53:57 PST
(In reply to comment #2)
> Don't we have a cleaner way to do this?

One idea was to use OwnPtr, but I was concerned that there might be a race condition between the time we copy the data structure pointed to by param in wtfThreadEntryPoint() and when the OwnPtr goes out of scope when we reach the end of createThreadInternal().

I'll look into this some more. If you have any insight/suggestions I would appreciate it.
Comment 4 Daniel Bates 2011-01-04 10:46:58 PST
Created attachment 77904 [details]
Patch

Use OwnPtr based on a suggestion by Adam Roben for bug #51855
Comment 5 Daniel Bates 2011-01-04 10:49:35 PST
Created attachment 77905 [details]
Patch
Comment 6 Daniel Bates 2011-01-04 11:29:55 PST
Committed r74983: <http://trac.webkit.org/changeset/74983>