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

Issue 178543013: Fix a bug in Range::didSplitTextNode() that may yield an invalid Range object. (Closed)

Created:
6 years, 9 months ago by Yuta Kitamura
Modified:
6 years, 9 months ago
Reviewers:
yoichio, tkent, yosin_UTC9
CC:
blink-reviews, sof, eae+blinkwatch, dglazkov+blink, adamk+blink_chromium.org, Inactive, rwlbuis
Visibility:
Public.

Description

Fix a bug in Range::didSplitTextNode() that may yield an invalid Range object. Range::didSplitTextNode() fails to update RangeBoundaryPoint's m_childBeforeBoundary correctly, if either boundary point is located immediately after the split text node. This change fixes this bug and adds a couple of unit tests that make sure text splits are handled correctly. This is a bug I found while I was investigating on a ClusterFuzz crash. The bug above was the root cause of the crash. The crash happens in the following way: 1. Range::surroundContents() removes some nodes during its operation, which causes DOMNodeRemoved event to fire *before* surroundContents() completes. 2. A user-supplied event handler does something causing text to split. 3. Due to the bug above, Range's boundary points may get into an inconsistent state; i.e. m_start may be located *after* m_end. 4. If certain conditions are met, an invalid Range object created during Range::surroundContents() causes a crash within checkDeleteExtract(). 5. Sad face. This change adds a new layout test that reproduces this crash. BUG=343798 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=168521

Patch Set 1 #

Patch Set 2 : Fix comments in test. #

Total comments: 2

Patch Set 3 : Fix conflicts. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+241 lines, -5 lines) Patch
A LayoutTests/fast/dom/Range/surroundContents-crash.html View 1 1 chunk +70 lines, -0 lines 0 comments Download
A LayoutTests/fast/dom/Range/surroundContents-crash-expected.txt View 1 chunk +20 lines, -0 lines 0 comments Download
M Source/core/core.gypi View 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/dom/Range.cpp View 1 2 3 chunks +8 lines, -5 lines 0 comments Download
A Source/core/dom/RangeTest.cpp View 1 chunk +142 lines, -0 lines 0 comments Download

Messages

Total messages: 14 (0 generated)
Yuta Kitamura
This might be the most ridiculous ClusterFuzz bug I've ever seen... FWIW, ClusterFuzz's original repro ...
6 years, 9 months ago (2014-03-04 06:20:31 UTC) #1
yosin_UTC9
ACK https://codereview.chromium.org/178543013/diff/20001/LayoutTests/fast/dom/Range/surroundContents-crash.html File LayoutTests/fast/dom/Range/surroundContents-crash.html (right): https://codereview.chromium.org/178543013/diff/20001/LayoutTests/fast/dom/Range/surroundContents-crash.html#newcode32 LayoutTests/fast/dom/Range/surroundContents-crash.html:32: textToBeRemoved.addEventListener('DOMNodeRemoved', function (event) { nit: Can we use ...
6 years, 9 months ago (2014-03-04 09:26:29 UTC) #2
yosin_UTC9
LGTM Sorry, I should put LGTM instead of ACK.
6 years, 9 months ago (2014-03-05 01:09:07 UTC) #3
Yuta Kitamura
https://codereview.chromium.org/178543013/diff/20001/LayoutTests/fast/dom/Range/surroundContents-crash.html File LayoutTests/fast/dom/Range/surroundContents-crash.html (right): https://codereview.chromium.org/178543013/diff/20001/LayoutTests/fast/dom/Range/surroundContents-crash.html#newcode32 LayoutTests/fast/dom/Range/surroundContents-crash.html:32: textToBeRemoved.addEventListener('DOMNodeRemoved', function (event) { On 2014/03/04 09:26:29, Yoshi wrote: ...
6 years, 9 months ago (2014-03-05 01:15:52 UTC) #4
Yuta Kitamura
Kent-san, can you take a look as an OWNER?
6 years, 9 months ago (2014-03-05 01:16:09 UTC) #5
tkent
On 2014/03/05 01:16:09, Yuta Kitamura wrote: > Kent-san, can you take a look as an ...
6 years, 9 months ago (2014-03-05 03:05:26 UTC) #6
Yuta Kitamura
On 2014/03/05 03:05:26, tkent wrote: > On 2014/03/05 01:16:09, Yuta Kitamura wrote: > > Kent-san, ...
6 years, 9 months ago (2014-03-05 03:11:33 UTC) #7
Yuta Kitamura
The CQ bit was checked by yutak@chromium.org
6 years, 9 months ago (2014-03-05 03:11:36 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/yutak@chromium.org/178543013/20001
6 years, 9 months ago (2014-03-05 03:12:11 UTC) #9
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 9 months ago (2014-03-05 03:12:13 UTC) #10
commit-bot: I haz the power
Failed to apply patch for Source/core/dom/Range.cpp: While running patch -p1 --forward --force --no-backup-if-mismatch; patching file ...
6 years, 9 months ago (2014-03-05 03:12:14 UTC) #11
Yuta Kitamura
The CQ bit was checked by yutak@chromium.org
6 years, 9 months ago (2014-03-05 03:38:26 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/yutak@chromium.org/178543013/40001
6 years, 9 months ago (2014-03-05 03:38:46 UTC) #13
commit-bot: I haz the power
6 years, 9 months ago (2014-03-05 19:39:44 UTC) #14
Message was sent while issue was closed.
Change committed as 168521

Powered by Google App Engine
This is Rietveld 408576698