Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Issue 23005006: Fix XMLHttpRequest leak document when send() is called multiple times. (Closed)

Created:
7 years, 4 months ago by kouhei (in TOK)
Modified:
7 years, 4 months ago
CC:
blink-reviews, dglazkov+blink, eae+blinkwatch
Visibility:
Public.

Description

Fix XMLHttpRequest leak document when send() is called multiple times. XMLHttpRequest creates a ThreadableLoader which may call XHR async, so it setPendingActivity() to avoid being destroyed. However, before this patch, unsetPendingActivity() was called asynchronously after ThreadableLoader was destroyed, so it lead to multiple problems: a) When next m_loader was set in send() with pending unsetPendingActivity(), the pendingActivity may be dropped even when there exists new m_loader need protection. b) pendingActivity may be set multiple times from pending unsetPendingActivity(), but dropProtectionSoon() only decrements m_pendingActivityCount by one, leading to a leak. This patch fix the above problems by unsetPendingActivity() synchronously with m_loader destruction where possible. XMLHttpRequest::stop() still uses asynchronous unsetPendingActivity() to workaround issues mentioned in r152266. The file "leak-check.js" was moved from fast/dom to fast/js to enable access from http tests. BUG=270000 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=156078 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=156456

Patch Set 1 #

Total comments: 2

Patch Set 2 : try to sync unsetPendingActivity where possible #

Total comments: 4

Patch Set 3 : styles #

Total comments: 2

Patch Set 4 : use default argument #

Patch Set 5 : omit default #

Patch Set 6 : omit default args (somehow my changes are getting lost) #

Patch Set 7 : unsetPendingActivity before changeState() #

Total comments: 2

Patch Set 8 : rebase #

Patch Set 9 : retain unconditionally #

Patch Set 10 : check readyState == 4 to comply with change made in r156212 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+56 lines, -92 lines) Patch
M LayoutTests/accessibility/axobjectcache-leaks-node.html View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M LayoutTests/editing/context-menu-leak-document.html View 1 1 chunk +1 line, -1 line 0 comments Download
M LayoutTests/editing/selection/leak-document-with-selection-inside.html View 1 chunk +1 line, -1 line 0 comments Download
M LayoutTests/fast/dom/NodeIterator/NodeIterator-leak-document.html View 1 chunk +1 line, -1 line 0 comments Download
M LayoutTests/fast/dom/TreeWalker/TreeWalker-leak-document.html View 1 chunk +1 line, -1 line 0 comments Download
D LayoutTests/fast/dom/resources/leak-check.js View 1 chunk +0 lines, -69 lines 0 comments Download
M LayoutTests/fast/events/event-sender-context-click-leak-document.html View 1 chunk +1 line, -1 line 0 comments Download
A LayoutTests/http/tests/xmlhttprequest/resources/multiple-send.html View 1 2 3 4 5 6 7 8 9 1 chunk +11 lines, -0 lines 0 comments Download
A LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-leaks-on-multiple-send.html View 1 chunk +12 lines, -0 lines 0 comments Download
A + LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-leaks-on-multiple-send-expected.txt View 1 2 3 4 5 6 7 0 chunks +-1 lines, --1 lines 0 comments Download
M Source/core/xml/XMLHttpRequest.h View 1 2 3 4 5 6 7 2 chunks +6 lines, -1 line 0 comments Download
M Source/core/xml/XMLHttpRequest.cpp View 1 2 3 4 5 6 7 8 4 chunks +22 lines, -17 lines 0 comments Download

Messages

Total messages: 23 (0 generated)
kouhei (in TOK)
abarth, haraken: Would you take a look?
7 years, 4 months ago (2013-08-14 01:20:33 UTC) #1
haraken
https://codereview.chromium.org/23005006/diff/1/Source/core/xml/XMLHttpRequest.cpp File Source/core/xml/XMLHttpRequest.cpp (right): https://codereview.chromium.org/23005006/diff/1/Source/core/xml/XMLHttpRequest.cpp#newcode764 Source/core/xml/XMLHttpRequest.cpp:764: if (!hasPendingActivity()) I'm not sure if this is a ...
7 years, 4 months ago (2013-08-14 01:30:58 UTC) #2
kouhei (in TOK)
Updated patch. Would you take a look? https://codereview.chromium.org/23005006/diff/1/Source/core/xml/XMLHttpRequest.cpp File Source/core/xml/XMLHttpRequest.cpp (right): https://codereview.chromium.org/23005006/diff/1/Source/core/xml/XMLHttpRequest.cpp#newcode764 Source/core/xml/XMLHttpRequest.cpp:764: if (!hasPendingActivity()) ...
7 years, 4 months ago (2013-08-14 02:30:09 UTC) #3
haraken
LGTM. abarth might want to take another look. https://codereview.chromium.org/23005006/diff/7001/Source/core/xml/XMLHttpRequest.cpp File Source/core/xml/XMLHttpRequest.cpp (right): https://codereview.chromium.org/23005006/diff/7001/Source/core/xml/XMLHttpRequest.cpp#newcode759 Source/core/xml/XMLHttpRequest.cpp:759: ASSERT(!hasPendingActivity()); ...
7 years, 4 months ago (2013-08-14 02:35:06 UTC) #4
kouhei (in TOK)
abarth: Would you take a look? https://codereview.chromium.org/23005006/diff/7001/Source/core/xml/XMLHttpRequest.cpp File Source/core/xml/XMLHttpRequest.cpp (right): https://codereview.chromium.org/23005006/diff/7001/Source/core/xml/XMLHttpRequest.cpp#newcode759 Source/core/xml/XMLHttpRequest.cpp:759: ASSERT(!hasPendingActivity()); On 2013/08/14 ...
7 years, 4 months ago (2013-08-14 03:19:30 UTC) #5
abarth-chromium
https://codereview.chromium.org/23005006/diff/18001/Source/core/xml/XMLHttpRequest.cpp File Source/core/xml/XMLHttpRequest.cpp (right): https://codereview.chromium.org/23005006/diff/18001/Source/core/xml/XMLHttpRequest.cpp#newcode1233 Source/core/xml/XMLHttpRequest.cpp:1233: internalAbort(DropProtectionAsync); What I would do is make DropProtectionSync the ...
7 years, 4 months ago (2013-08-14 04:11:48 UTC) #6
kouhei (in TOK)
Thank you for the review! https://codereview.chromium.org/23005006/diff/18001/Source/core/xml/XMLHttpRequest.cpp File Source/core/xml/XMLHttpRequest.cpp (right): https://codereview.chromium.org/23005006/diff/18001/Source/core/xml/XMLHttpRequest.cpp#newcode1233 Source/core/xml/XMLHttpRequest.cpp:1233: internalAbort(DropProtectionAsync); On 2013/08/14 04:11:49, ...
7 years, 4 months ago (2013-08-14 04:58:20 UTC) #7
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/kouhei@chromium.org/23005006/25001
7 years, 4 months ago (2013-08-14 04:58:39 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/kouhei@chromium.org/23005006/2001
7 years, 4 months ago (2013-08-14 05:02:37 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/kouhei@chromium.org/23005006/39001
7 years, 4 months ago (2013-08-14 05:24:11 UTC) #10
commit-bot: I haz the power
Change committed as 156078
7 years, 4 months ago (2013-08-14 07:49:15 UTC) #11
kouhei (in TOK)
Change was reverted as r156082
7 years, 4 months ago (2013-08-14 08:41:14 UTC) #12
kouhei (in TOK)
abarth: Would you take a look? The CL failed to land as ASSERT(!hasPendingActivity()); failed in ...
7 years, 4 months ago (2013-08-15 04:08:39 UTC) #13
haraken
On 2013/08/15 04:08:39, kouhei wrote: > abarth: Would you take a look? > > The ...
7 years, 4 months ago (2013-08-15 04:53:54 UTC) #14
kouhei (in TOK)
> LGTM. abarth might want to take another look. abarth: Would you take a look? ...
7 years, 4 months ago (2013-08-16 06:00:07 UTC) #15
abarth-chromium
lgtm https://chromiumcodereview.appspot.com/23005006/diff/50001/Source/core/xml/XMLHttpRequest.cpp File Source/core/xml/XMLHttpRequest.cpp (right): https://chromiumcodereview.appspot.com/23005006/diff/50001/Source/core/xml/XMLHttpRequest.cpp#newcode1091 Source/core/xml/XMLHttpRequest.cpp:1091: protect = this; I probably would have just ...
7 years, 4 months ago (2013-08-19 17:53:17 UTC) #16
abarth-chromium
Sorry for the delay in reviewing.
7 years, 4 months ago (2013-08-19 17:53:23 UTC) #17
kouhei (in TOK)
Thanks for the review! https://codereview.chromium.org/23005006/diff/50001/Source/core/xml/XMLHttpRequest.cpp File Source/core/xml/XMLHttpRequest.cpp (right): https://codereview.chromium.org/23005006/diff/50001/Source/core/xml/XMLHttpRequest.cpp#newcode1091 Source/core/xml/XMLHttpRequest.cpp:1091: protect = this; On 2013/08/19 ...
7 years, 4 months ago (2013-08-19 23:44:59 UTC) #18
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/kouhei@chromium.org/23005006/69001
7 years, 4 months ago (2013-08-20 00:06:28 UTC) #19
commit-bot: I haz the power
Retried try job too often on linux_blink_rel for step(s) webkit_tests http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=linux_blink_rel&number=2415
7 years, 4 months ago (2013-08-20 01:43:19 UTC) #20
kouhei (in TOK)
It seems that there was a sanity check added to XHR::send(). Updated the LayoutTest to ...
7 years, 4 months ago (2013-08-21 06:17:10 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/kouhei@chromium.org/23005006/77001
7 years, 4 months ago (2013-08-21 06:17:27 UTC) #22
commit-bot: I haz the power
7 years, 4 months ago (2013-08-21 08:20:23 UTC) #23
Message was sent while issue was closed.
Change committed as 156456

Powered by Google App Engine
This is Rietveld 408576698