| Summary: | Resource leak in object - memory allocated in constructor but not freed in destructor. | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Albert Malewski <a.malewski> | ||||||||
| Component: | WebCore Misc. | Assignee: | Nobody <webkit-unassigned> | ||||||||
| Status: | NEW --- | ||||||||||
| Severity: | Normal | CC: | ap, beidson, commit-queue, gyuyoung.kim, japhet, kling, m.leszko, mpakulavelrutka | ||||||||
| Priority: | P2 | ||||||||||
| Version: | 528+ (Nightly build) | ||||||||||
| Hardware: | Unspecified | ||||||||||
| OS: | Unspecified | ||||||||||
| Attachments: |
|
||||||||||
|
Description
Albert Malewski
2014-08-18 04:39:35 PDT
Created attachment 236759 [details]
Patch
Comment on attachment 236759 [details]
Patch
m_nonHTTPProtocolHost should be a std::unique_ptr<HostInformation> instead. That way we don't have to manually delete it.
Does the leak occur in practice? It looks like ResourceLoadScheduler object is a singleton, and is never expected to be deleted. Unless I'm misreading the code, what needs to be fixed is: 1. We should have ASSERT_NOT_REACHED in the destructor. 2. WebResourceLoadScheduler (a subclass of ResourceLoadScheduler) should not have a public constructor. (In reply to comment #3) In my opinion, WebResourceLoadScheduler should have a public constructor because it is used in WebProcess class. Of course, we can mark WebProcess class as a friend of WebResourceLoadScheduler, but I think it does not make any sense, because in result it does not change anything.. Created attachment 236811 [details]
Patch
Comment on attachment 236811 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=236811&action=review It’s kind of weak to use unique_ptr for m_nonHTTPProtocolHost but not do the same thing for the hosts in m_hosts. > Source/WebCore/ChangeLog:3 > + Fixed resource leak in object This is not a good name for a bug. It’s much too vague. Almost like “fixed bug in project”. And also, it’s inaccurate. This patch doesn’t fix a leak. It makes some inconsequential changes in a class, which I suppose could be helpful if someone didn’t realize the object was an immortal singleton. > Source/WebCore/ChangeLog:8 > + Changed m_nonHTTPProtocolHost from HostInformation* to std::unique_ptr<HostInformation> and added ASSERT_NOT_REACHED() in the destructor. It’s a little strange to do both of these things. It’s correct to assert that the destructor is never called. That’s what makes it clear we don’t really need a unique_ptr. But I suppose it’s OK to use unique_ptr just to be a little clearer about object ownership. > Source/WebCore/loader/ResourceLoadScheduler.cpp:107 > + m_nonHTTPProtocolHost = std::make_unique<ResourceLoadScheduler::HostInformation>(String(), maxRequestsInFlightForNonHTTPProtocols); Why change from construction syntax to assignment syntax? For unique_ptr that’s less efficient for no good reason. Just seems like gratuitous “make coding style a little worse” change. > In my opinion, WebResourceLoadScheduler should have a public constructor because it is used in WebProcess class.
Yes, this is how it is used today. What I was getting at is that this design appears wrong, because it requires exposing a public constructor for a singleton.
Created attachment 237061 [details]
Patch
Created a patch with changed access to constructor of WebResourceLoadScheduler: https://bugs.webkit.org/show_bug.cgi?id=136126 Created a patch with changed access to constructor of WebResourceLoadScheduler: https://bugs.webkit.org/show_bug.cgi?id=136126 Comment on attachment 237061 [details]
Patch
Hi,
Apologies that your patch was not reviewed in a timely manner. Since it's now quite old, I am removing it from the review request queue. Please consider rebasing it on trunk and resubmitting.
To increase the chances of getting a review, consider using 'Tools/Scripts/webkit-patch upload --suggest-reviewers' to CC reviewers who might be interested in this bug.
|