WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 28710
Copy some forms of text causes Webkit crash in CSSStyleDeclaration::copyPropertiesInSet
https://bugs.webkit.org/show_bug.cgi?id=28710
Summary
Copy some forms of text causes Webkit crash in CSSStyleDeclaration::copyPrope...
matthew.c.henderson
Reported
2009-08-25 07:58:59 PDT
Went here
http://classicalmusic.about.com/od/romanticperiodsymphonies/qt/Beethovenjoytxt.htm
selected the translation text "O friends.... above the stars must he dwell." I did a command-C to copy the text. As the mouse pointer was going to the text editor window, Webkit crashed. repeated several times until deciding to report this bug. Note: Could copy text off of the Webkit startup "nightly build" web page without crashing
Attachments
reduction, copy "first paragraph" and crashes WebKit.
(89 bytes, text/html)
2009-08-26 20:09 PDT
,
Ryosuke Niwa
no flags
Details
attempt to fix the bug but needs DRT test
(2.13 KB, patch)
2009-08-31 22:32 PDT
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
another test
(150 bytes, text/html)
2009-08-31 22:50 PDT
,
Ryosuke Niwa
no flags
Details
2nd attempt to fix the bug, requires rebaseline & DRT test
(4.74 KB, patch)
2009-09-03 17:01 PDT
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
fixes the bug but requires a lot of rebaselines
(25.06 KB, patch)
2009-09-09 11:45 PDT
,
Ryosuke Niwa
eric
: review-
Details
Formatted Diff
Diff
A super-quick fix written in an hour
(7.51 KB, patch)
2009-09-10 22:20 PDT
,
Hironori Bono
no flags
Details
Formatted Diff
Diff
The second quick fix
(7.51 KB, patch)
2009-10-05 03:32 PDT
,
Hironori Bono
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
mitz
Comment 1
2009-08-25 08:58:47 PDT
Please attach a crash log <
http://webkit.org/quality/crashlogs.html
>
Alexey Proskuryakov
Comment 2
2009-08-25 22:55:36 PDT
I can reproduce this with a local debug build of
r47661
, stack trace: #0 0x03a6102f in WebCore::CSSStyleDeclaration::copyPropertiesInSet at CSSStyleDeclaration.cpp:153 #1 0x0396b118 in WebCore::editingStyleAtPosition at ApplyStyleCommand.cpp:386 #2 0x03fb0ed1 in WebCore::createMarkup at markup.cpp:1007 #3 0x03f8f44b in WebCore::LegacyWebArchive::createFromSelection at LegacyWebArchive.cpp:567 #4 0x04007cae in WebCore::Pasteboard::writeSelection at PasteboardMac.mm:166 #5 0x04008180 in WebCore::Pasteboard::writeSelection at PasteboardMac.mm:203 #6 0x03bd911b in WebCore::Editor::copy at Editor.cpp:1035 #7 0x03bde8c7 in WebCore::executeCopy at EditorCommand.cpp:284 #8 0x03bdc3a3 in WebCore::Editor::Command::execute at EditorCommand.cpp:1504 #9 0x00e05ed6 in -[WebHTMLView executeCoreCommandBySelector:] at WebHTMLView.mm:2360 #10 0x00df6f8b in -[WebHTMLView copy:] at WebHTMLView.mm:2382 <..>
mitz
Comment 3
2009-08-25 22:59:00 PDT
<
rdar://problem/7170666
>
Ryosuke Niwa
Comment 4
2009-08-26 09:56:00 PDT
Crash report. Version:
r47686
(47686) Code Type: X86 (Native) Date/Time: 2009-08-26 09:51:48.256 -0700 OS Version: Mac OS X 10.5.8 (9L31a) Report Version: 6 Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000 0 com.apple.WebCore 0x00fa1d50 WebCore::CSSStyleDeclaration::copyPropertiesInSet(int const*, unsigned int) const + 144 1 com.apple.WebCore 0x00f088a0 WebCore::editingStyleAtPosition(WebCore::Position, WebCore::ShouldIncludeTypingStyle) + 80 2 com.apple.WebCore 0x014a21bf WebCore::createMarkup(WebCore::Range const*, WTF::Vector<WebCore::Node*, 0ul>*, WebCore::EAnnotateForInterchange, bool) + 4687 3 com.apple.WebCore 0x01485e14 WebCore::LegacyWebArchive::createFromSelection(WebCore::Frame*) + 132 4 com.apple.WebCore 0x014d9e02 WebCore::Pasteboard::writeSelection(NSPasteboard*, WebCore::Range*, bool, WebCore::Frame*) + 1410 5 com.apple.WebCore 0x010c107d WebCore::Editor::copy() + 269 6 com.apple.WebCore 0x010ca469 __ZN7WebCoreL11executeCopyEPNS_5FrameEPNS_5EventENS_19EditorCommandSourceERKNS_6StringE + 25 7 com.apple.WebCore 0x010c8dfe WebCore::Editor::Command::execute(WebCore::String const&, WebCore::Event*) const + 110 8 com.apple.WebKit 0x0032a4a7 -[WebHTMLView executeCoreCommandBySelector:] + 135
Ryosuke Niwa
Comment 5
2009-08-26 10:53:41 PDT
Did not reproduce on TOT. Can someone else try it?
Ryosuke Niwa
Comment 6
2009-08-26 19:26:15 PDT
(In reply to
comment #5
)
> Did not reproduce on TOT. Can someone else try it?
Finally managed to reproduce. 385 RefPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = pos.computedStyle(); is returning 0.
Ryosuke Niwa
Comment 7
2009-08-26 20:09:46 PDT
Created
attachment 38655
[details]
reduction, copy "first paragraph" and crashes WebKit. This crash is caused by a bug that the computed style is null if text-decoration is set to inherit at the html node.
Ryosuke Niwa
Comment 8
2009-08-31 20:02:35 PDT
I did some investigation with the test case I posted.
http://trac.webkit.org/browser/trunk/WebCore/dom/Position.cpp#L199
On the line 211, anchorNode() is returning the html node, and n->isElementNode() is returning false so that n->parentNode() is called on n=html element. editingStyleAtPosition is called from
http://trac.webkit.org/browser/trunk/WebCore/editing/markup.cpp#L1005
parentOfLastClosed is also html element. When text-decoration: inherit is removed from the html element, the position points to div, and everything works fine.
Ryosuke Niwa
Comment 9
2009-08-31 20:25:35 PDT
In createMarkup, specialCommonAncestor is null normally but it's set to the html element with text-decoration: inherit property on html element. The problem is caused by the line 950 of markup.cpp where we find the highest enclosing node, which is presentational. On the line 712, we check whether text decoration exist or not by checking whether it's equal to none or inherit. But we should also ignore inherit because inherit = none for the purpose of this function. return !propertyMissingOrEqualToNone(style.get(), CSSPropertyTextDecoration);
http://trac.webkit.org/browser/trunk/WebCore/editing/markup.cpp#L948
http://trac.webkit.org/browser/trunk/WebCore/editing/markup.cpp#L704
Ryosuke Niwa
Comment 10
2009-08-31 22:32:13 PDT
Created
attachment 38845
[details]
attempt to fix the bug but needs DRT test This patch modifies propertyMissingOrEqualToNone to propertyMissingOrEqualToNoneOrInherit. Need a DRT test and changelog.
Ryosuke Niwa
Comment 11
2009-08-31 22:50:16 PDT
Created
attachment 38846
[details]
another test Even if my attempt was accepted, WebKit still crashes when html element has text-decoration. I feel like this problem will be solved if isElement() was true for html element. I don't really understand why this is not the case.
Alexey Proskuryakov
Comment 12
2009-08-31 23:35:50 PDT
isElementNode() should be true for the HTML element, but not for the Document node (which is its parent). Looks like the problem here is that a position's anchor node is the document node, which makes Position::element() return null.
Alexey Proskuryakov
Comment 13
2009-09-01 10:53:45 PDT
***
Bug 28807
has been marked as a duplicate of this bug. ***
Jeremy Moskovich
Comment 14
2009-09-02 10:55:09 PDT
Chromium bug tracker URL:
http://crbug.com/20891
Ryosuke Niwa
Comment 15
2009-09-02 11:01:09 PDT
Here are some options to fix this bug. 1. We make sure document is not passed as node to editingStyleAtPosition in createMakrup 2. We allow position.computedStyle to use a document node. 3. We bail out in editingStyleAtPosition if the position returned a null pointer. There are several ways to implement 1, and I can't really think of a good one. But I don't think why any element with text-decoration must be a special ancestor. I feel like we can get away without making it special ancestor since we're adding computedStyle in a wrapping span later anyways.
Ryosuke Niwa
Comment 16
2009-09-03 16:23:48 PDT
I tried #2 but this method turned out to be insufficient. When allowing html elemenet to be a special ancestor causes the style attribute of the html element in inside which the fragment is pasted to be modififed. To solve this problem, we should disallow elements with text-decoration property to be a special ancestor, and should use StyleChange class from ApplyStyleCommand.
Ryosuke Niwa
Comment 17
2009-09-03 17:01:30 PDT
Created
attachment 39020
[details]
2nd attempt to fix the bug, requires rebaseline & DRT test As I described above, we need to export StyleChange from ApplyStyleCommand and use it in createMarkup. But that means we might end up wrapping a bunch of block elements with b, s, etc... But this requires substential architectual change of the editing code (takes at least several months). So for time being, we can ignore StyleWithCSS=false, and just fix the crash. This patch tries to modify Position::computedStyle to allow document node to be passed to computedStyle. In addition, it modifies isElementPresentational not to recognize html elements with text-decoration property. Instead of treating them as special ancestors, we'll preserve text decorations from the computed style when we wrap the content with style span if necessary. This patch somehow caused a whole bunch of tests to fail because WebKit spits out a bunch of annoymous nodes and empty text nodes. Does anyone know why this happens?
Ryosuke Niwa
Comment 18
2009-09-03 17:05:46 PDT
Comment on
attachment 39020
[details]
2nd attempt to fix the bug, requires rebaseline & DRT test Make my patch r? even though I don't intend to land this patch at all. I just need some feedback on my approach here.
Eric Seidel (no email)
Comment 19
2009-09-08 10:10:51 PDT
Comment on
attachment 39020
[details]
2nd attempt to fix the bug, requires rebaseline & DRT test This will need a layout test in the end. Not sure what about this approach you want feedback on. Probably best to just post a "final" patch that can be actually reviewed.
Justin Garcia
Comment 20
2009-09-08 12:56:44 PDT
+ ContainerNode* elem = element(); + // Allow document node to be passed if there Comment is unnecessary since it just says what the code does.
> This patch somehow caused a whole bunch of tests to fail > because WebKit spits out a bunch of annoymous nodes and > empty text nodes. Does anyone know why this happens?
Could you attach those diffs? // All text-decoration-related elements should have been treated as special ancestors // If we ever hit this ASSERT, we should export StyleChange in ApplyStyleCommand and use it here - ASSERT(propertyMissingOrEqualToNone(style, CSSPropertyTextDecoration) && propertyMissingOrEqualToNone(style, CSSPropertyWebkitTextDecorationsInEffect)); + ASSERT(propertyMissingOrEqualToNone(style, CSSPropertyWebkitTextDecorationsInEffect)); I think that the comment needs to be updated.
Ryosuke Niwa
Comment 21
2009-09-09 11:45:41 PDT
Created
attachment 39286
[details]
fixes the bug but requires a lot of rebaselines
Hironori Bono
Comment 22
2009-09-10 22:20:03 PDT
Created
attachment 39409
[details]
A super-quick fix written in an hour This is a super-quick workaround for this bug written this morning. (I haven't noticed you have been working for this bug.) Even though it is nothing but a better-than-crash fix, I wish this helps you.
Ryosuke Niwa
Comment 23
2009-09-22 12:06:09 PDT
(In reply to
comment #22
)
> Created an attachment (id=39409) [details] > A super-quick fix written in an hour > > This is a super-quick workaround for this bug written this morning. (I haven't > noticed you have been working for this bug.) > Even though it is nothing but a better-than-crash fix, I wish this helps you.
Your patch fixes the crash but doesn't fix the problem caused this crash: passing a null pointer to editingStyleAtPosition. We should never be passing a null pointer to editingStyleAtPosition because it doesn't make sense to obtain the editing style at null position.
Justin Garcia
Comment 24
2009-09-22 12:07:44 PDT
Ryosuke, did you scope out the DOM changes that are going on with some of these layout tests? I'd be interested to see what's going on...I think in most cases it's just some unrendered whitespace from the original HTML that's no longer cleared away by editing.
Eric Seidel (no email)
Comment 25
2009-09-25 11:02:15 PDT
Sigh. So this is the top WebKit crasher for Chromium. We need to get a fix in. I'm not sure reading Ryosuke's patch if the rebaselining is correct. I'll see if I can't catch him over IRC or GChat and ask him.
Eric Seidel (no email)
Comment 26
2009-09-25 11:04:54 PDT
It seems like Niwa's change does too much, and Bono's change does too little. :(
Eric Seidel (no email)
Comment 27
2009-09-25 12:24:31 PDT
Comment on
attachment 39286
[details]
fixes the bug but requires a lot of rebaselines The anonymous nodes are wrong. :( We chatted some about this over IRC. I think we need to try for a more surgical fix.
Ryosuke Niwa
Comment 28
2009-09-25 12:32:00 PDT
Talked with Eric S. on IRC, and concluded that we should use Bono's patch for now since this is a major crash bug even though his patch does not fix the actual behavior of WebKit that it attemps to copy html element only if it has text-decoration style. (this results in the modification of the html element of the document into which the content.) We should file a separate bug to fix these issues, and assert that position.node() is not NULL in editingStyleAtPosition in later patch.
Ryosuke Niwa
Comment 29
2009-09-25 17:24:44 PDT
Investigated LayoutTests/editing/pasteboard/display-block-on-spans.html. It turned out that there were no change in the DOM generated. Anonymous node seems to be created in renderer. Can somene explain to me when/how anonymous nodes are made? I tried to follow find it on XCode debugger, but I couldn't locate where the nodes are generated. (No difference in showTreeForThis) Meanwhile, it seems like we could convert the tests that require rebaseline in my patch to dumpAsText tests first because we can separte it (that WebKit generates anonymous node in this case) into another bug if the resultant DOMs are same. If people don't mind, I'd like to use my patch as is, or after converting tests to dumpAsText tests that spits out HTML instead of render tree. Any opinions?
Hironori Bono
Comment 30
2009-10-05 03:32:03 PDT
Created
attachment 40616
[details]
The second quick fix I would like to upload another better-than-crash patch as requested by Eric. I agree with the comment of Niwa-san that this patch isn't a good fix. I wish someone writes a better fix. :)
Eric Seidel (no email)
Comment 31
2009-10-05 08:12:40 PDT
Comment on
attachment 40616
[details]
The second quick fix Looks fine to me. Ryosuke wanted to do a follow-up fix, but given how common this crasher is (most common WebKit-related crasher in Chrome), I think we should get this minimal fix in first.
Eric Seidel (no email)
Comment 32
2009-10-05 10:58:35 PDT
Comment on
attachment 40616
[details]
The second quick fix Bono-san is not a committer according to
http://trac.webkit.org/browser/trunk/WebKitTools/Scripts/modules/committers.py
, so I'm adding cq+ to get this landed.
WebKit Commit Bot
Comment 33
2009-10-05 14:27:15 PDT
Comment on
attachment 40616
[details]
The second quick fix Rejecting patch 40616 from commit-queue. Failed to run "['WebKitTools/Scripts/run-webkit-tests', '--no-launch-safari', '--quiet', '--exit-after-n-failures=1']" exit_code: 1 Running build-dumprendertree Running tests from /Users/eseidel/Projects/CommitQueue/LayoutTests Testing 11380 test cases. fast/dom/prototype-inheritance.html -> failed Exiting early after 1 failures. 5489 tests run. 134.88s total testing time 5488 test cases (99%) succeeded 1 test case (<1%) had incorrect layout 1 test case (<1%) had stderr output
Eric Seidel (no email)
Comment 34
2009-10-05 14:41:27 PDT
Comment on
attachment 40616
[details]
The second quick fix The buildbots were behind. bugzilla-tool checked them, saw they were green, but they shouldn't have been. This was not your fault.
Eric Seidel (no email)
Comment 35
2009-10-05 15:02:18 PDT
False rejection was caused by
bug 30098
.
WebKit Commit Bot
Comment 36
2009-10-05 16:26:34 PDT
Comment on
attachment 40616
[details]
The second quick fix Clearing flags on attachment: 40616 Committed
r49129
: <
http://trac.webkit.org/changeset/49129
>
WebKit Commit Bot
Comment 37
2009-10-05 16:26:42 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug