Bug 51860 - LEAK: Deallocate instance of ThreadFunctionInvocation if thread creation fails
Summary: LEAK: Deallocate instance of ThreadFunctionInvocation if thread creation fails
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows XP
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-03 18:06 PST by Daniel Bates
Modified: 2011-01-04 11:29 PST (History)
2 users (show)

See Also:


Attachments
Patch (1.65 KB, patch)
2011-01-03 18:08 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (1.84 KB, patch)
2011-01-04 10:46 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (2.43 KB, patch)
2011-01-04 10:49 PST, Daniel Bates
aroben: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>