RESOLVED FIXED Bug 28412
Leak of WebCore::XMLHttpRequest object during layout tests
https://bugs.webkit.org/show_bug.cgi?id=28412
Summary Leak of WebCore::XMLHttpRequest object during layout tests
Mark Rowe (bdash)
Reported 2009-08-17 16:26:26 PDT
Created attachment 35001 [details] Make XHR leak more obvious While looking at the output of 'run-webkit-tests --leaks' over the last few days I've occasionally noticed instances of WebCore::XMLHttpRequest being leaked. I wrote a simple patch that uses RefCountedLeakCounter to make it more obvious when this sort of leak is occurring, and narrowed the leaks down to two tests that are run in sequence. The following command leaks a single XMLHttpRequest instance every time: ./WebKitTools/Scripts/run-webkit-tests --leaks LayoutTests/http/tests/xmlhttprequest/{xhr-onunload,xml-encoding}.html With the attached patch applied you'll see: LEAK: 1 XMLHttpRequest in the output.
Attachments
Make XHR leak more obvious (1.44 KB, patch)
2009-08-17 16:26 PDT, Mark Rowe (bdash)
no flags
Unfinished fix (1.90 KB, patch)
2009-08-18 14:03 PDT, Alexey Proskuryakov
no flags
Combination of previous two patches, plus ChangeLogs (4.65 KB, patch)
2009-08-18 19:01 PDT, Aaron Boodman
mjs: review+
eric: commit-queue-
Mark Rowe (bdash)
Comment 1 2009-08-17 16:28:55 PDT
I poked at this briefly and it seemed that the XHR instance gained an extra ref during a call to setPendingActivity which was never balanced out.
Mark Rowe (bdash)
Comment 2 2009-08-17 19:11:34 PDT
Alexey Proskuryakov
Comment 3 2009-08-18 13:41:57 PDT
This regressed in <http://trac.webkit.org/changeset/47291>, where a call to setPendingActivity() was moved to before ThreadableLoader::create(). Even worse, nonCacheRequestInFlight() call was lost in the refactoring.
Aaron Boodman
Comment 4 2009-08-18 13:49:15 PDT
Whoops, I will this.
Alexey Proskuryakov
Comment 5 2009-08-18 14:03:45 PDT
Created attachment 35073 [details] Unfinished fix OK, here's what I already have - unfinished and untested. This also fixed a check before setReportUploadProgress() (which is only used by Chromium afaik).
Aaron Boodman
Comment 6 2009-08-18 19:01:07 PDT
Created attachment 35095 [details] Combination of previous two patches, plus ChangeLogs I verified this fixes the leak. Also, reran all LayoutTests, no regressions. And it looks correct, so not sure what else I can add.
Maciej Stachowiak
Comment 7 2009-08-18 19:05:44 PDT
Comment on attachment 35095 [details] Combination of previous two patches, plus ChangeLogs r=me
Mark Rowe (bdash)
Comment 8 2009-08-18 20:01:27 PDT
Landed in r47478.
Eric Seidel (no email)
Comment 9 2009-08-18 20:03:59 PDT
Comment on attachment 35095 [details] Combination of previous two patches, plus ChangeLogs Rejecting patch 35095 from commit-queue. This patch will require manual commit. Patch https://bugs.webkit.org/attachment.cgi?id=35095 from bug 28412 failed to download and apply.
Alexey Proskuryakov
Comment 10 2009-08-18 21:35:32 PDT
+ // For now we should only balance the nonCached request count for main-thread XHRs and not + // Worker XHRs, as the Cache is not thread-safe. + // This will become irrelevant after https://bugs.webkit.org/show_bug.cgi?id=27165 is resolved. By the way, it seems that moving this and related code to DocumentThreadableLoader could be a nice improvement while we wait for bug 27165.
Note You need to log in before you can comment on or make changes to this bug.