Bug 101133 - Crash when replacing parts of text inputs with content: url(...)
Summary: Crash when replacing parts of text inputs with content: url(...)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Takashi Sakamoto
URL:
Keywords: HasReduction
Depends on:
Blocks:
 
Reported: 2012-11-02 17:17 PDT by Elliott Sprehn
Modified: 2012-11-14 02:47 PST (History)
12 users (show)

See Also:


Attachments
Reduction (instant crash!) (126 bytes, text/html)
2012-11-02 17:18 PDT, Elliott Sprehn
no flags Details
Patch (3.41 KB, patch)
2012-11-07 03:20 PST, Takashi Sakamoto
no flags Details | Formatted Diff | Diff
Patch (4.31 KB, patch)
2012-11-12 19:50 PST, Takashi Sakamoto
no flags Details | Formatted Diff | Diff
Patch (5.56 KB, patch)
2012-11-12 23:40 PST, Takashi Sakamoto
no flags Details | Formatted Diff | Diff
Patch for landing (5.54 KB, patch)
2012-11-13 18:11 PST, Takashi Sakamoto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Elliott Sprehn 2012-11-02 17:17:07 PDT
When you replace a part of a text input with an image using content: url(...) we crash in WebCore::RenderTextControlSingleLine::layout()

    #0 0x7f3d63b22655 in WebCore::RenderTextControlSingleLine::layout() third_party/WebKit/Source/WebCore/rendering/RenderTextControlSingleLine.cpp:111
    #1 0x7f3d62f51f30 in WebCore::RenderObject::layoutIfNeeded() third_party/WebKit/Source/WebCore/rendering/RenderObject.h:662
    #2 0x7f3d630979d3 in WebCore::RenderBlock::layoutPositionedObjects(bool) third_party/WebKit/Source/WebCore/rendering/RenderBlock.cpp:2682
    #3 0x7f3d6308bc34 in WebCore::RenderBlock::layoutBlock(bool, WebCore::FractionalLayoutUnit) third_party/WebKit/Source/WebCore/rendering/RenderBlock.cpp:1588
    #4 0x7f3d63086cdd in WebCore::RenderBlock::layout() third_party/WebKit/Source/WebCore/rendering/RenderBlock.cpp:1383
    #5 0x7f3d62f51f30 in WebCore::RenderObject::layoutIfNeeded() third_party/WebKit/Source/WebCore/rendering/RenderObject.h:662
    #6 0x7f3d630979d3 in WebCore::RenderBlock::layoutPositionedObjects(bool) third_party/WebKit/Source/WebCore/rendering/RenderBlock.cpp:2682
    #7 0x7f3d6308bc34 in WebCore::RenderBlock::layoutBlock(bool, WebCore::FractionalLayoutUnit) third_party/WebKit/Source/WebCore/rendering/RenderBlock.cpp:1588
    #8 0x7f3d63086cdd in WebCore::RenderBlock::layout() third_party/WebKit/Source/WebCore/rendering/RenderBlock.cpp:1383


This is enough to cause it:

<style>
input::-webkit-textfield-decoration-container {
    content: url("");
}
</style>
<input type=number>

This is because of the hack in RenderObject::createObject where we swap out the correct renderer for an element with a RenderImage if content is specified and only has a url(...).

http://code.google.com/searchframe#OAMlx_jo-ck/src/third_party/WebKit/Source/WebCore/rendering/RenderObject.cpp&exact_package=chromium&q=RenderObject.cpp&type=cs&l=144
Comment 1 Elliott Sprehn 2012-11-02 17:18:26 PDT
Created attachment 172181 [details]
Reduction (instant crash!)
Comment 2 Elliott Sprehn 2012-11-02 17:49:10 PDT
I think the trivial fix for this is to override the content property in these cases:

http://code.google.com/searchframe#OAMlx_jo-ck/src/third_party/WebKit/Source/WebCore/html/TextFieldInputType.cpp&exact_package=chromium&q=textfield-decoration-container&type=cs&l=248

we should do

m_container->setInlineStyleProperty(CSSPropertyContent, "none", false);

as I can't fathom why you'd ever actually intend to swap out the entire inside of a text input with a content image.
Comment 3 Takashi Sakamoto 2012-11-07 03:20:58 PST
Created attachment 172749 [details]
Patch
Comment 4 Elliott Sprehn 2012-11-09 10:16:51 PST
Comment on attachment 172749 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=172749&action=review

> Source/WebCore/css/html.css:439
> +    content: none !important;

Do !important rules in author style sheets not override ones in the UA sheet?

> LayoutTests/fast/dom/HTMLInputElement/input-set-content-url-crash.html:5
> +    content: url("");

What happens if you put an !important here?
Comment 5 Eric Seidel (no email) 2012-11-09 12:57:41 PST
Comment on attachment 172749 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=172749&action=review

I think we need some sort of ASSERT or other guard in the C++ code to make sure we don't ever hit this again.  Right now if we removed that line we would start having this crash again. I suspect that's true of many lines in our UA file, but it still seems worthy of a C++ ASSERT to validate our understanding of the code's limitations.

>> Source/WebCore/css/html.css:439
>> +    content: none !important;
> 
> Do !important rules in author style sheets not override ones in the UA sheet?

UA sheets win:
http://www.w3.org/TR/CSS2/cascade.html#cascading-order
Comment 6 Takashi Sakamoto 2012-11-12 19:50:37 PST
Created attachment 173798 [details]
Patch
Comment 7 Takashi Sakamoto 2012-11-12 19:59:26 PST
Comment on attachment 172749 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=172749&action=review

Thank you for reviewing.

I added ASSERT to TextFieldInputType::attach() to confirm that container has no content data.

Best regards,
Takashi Sakamoto

>> LayoutTests/fast/dom/HTMLInputElement/input-set-content-url-crash.html:5
>> +    content: url("");
> 
> What happens if you put an !important here?

I agree that I should add !important here.
Done.
Comment 8 Kent Tamura 2012-11-12 22:49:08 PST
Comment on attachment 173798 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=173798&action=review

> Source/WebCore/ChangeLog:11
> +        Test: fast/dom/HTMLInputElement/input-set-content-url-crash.html

Would you put the test as fast/forms/number/number-content-url-crash.html please?
Also, this bug should happen with <input type=search>. We had better have the same test for type=search.
Comment 9 Takashi Sakamoto 2012-11-12 23:25:40 PST
Comment on attachment 173798 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=173798&action=review

>> Source/WebCore/ChangeLog:11
>> +        Test: fast/dom/HTMLInputElement/input-set-content-url-crash.html
> 
> Would you put the test as fast/forms/number/number-content-url-crash.html please?
> Also, this bug should happen with <input type=search>. We had better have the same test for type=search.

So... I know the following input types inherit from class TextFieldInputType:
- TextInputType
- URLInputType
- EmailInputType
- SearchInputType
- PasswordInputType
- TelephoneInputType
- NumberInputType
- BaseDateAndTimeInputType

We have to add the same test for above all types?
Comment 10 Kent Tamura 2012-11-12 23:30:55 PST
Comment on attachment 173798 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=173798&action=review

>>> Source/WebCore/ChangeLog:11
>>> +        Test: fast/dom/HTMLInputElement/input-set-content-url-crash.html
>> 
>> Would you put the test as fast/forms/number/number-content-url-crash.html please?
>> Also, this bug should happen with <input type=search>. We had better have the same test for type=search.
> 
> So... I know the following input types inherit from class TextFieldInputType:
> - TextInputType
> - URLInputType
> - EmailInputType
> - SearchInputType
> - PasswordInputType
> - TelephoneInputType
> - NumberInputType
> - BaseDateAndTimeInputType
> 
> We have to add the same test for above all types?

No. -webkit-textfield-decoration-container is used only in type=number and type=search.
Comment 11 Takashi Sakamoto 2012-11-12 23:39:49 PST
(In reply to comment #10)
> (From update of attachment 173798 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=173798&action=review
> 
> >>> Source/WebCore/ChangeLog:11
> >>> +        Test: fast/dom/HTMLInputElement/input-set-content-url-crash.html
> >> 
> >> Would you put the test as fast/forms/number/number-content-url-crash.html please?
> >> Also, this bug should happen with <input type=search>. We had better have the same test for type=search.
> > 
> > So... I know the following input types inherit from class TextFieldInputType:
> > - TextInputType
> > - URLInputType
> > - EmailInputType
> > - SearchInputType
> > - PasswordInputType
> > - TelephoneInputType
> > - NumberInputType
> > - BaseDateAndTimeInputType
> > 
> > We have to add the same test for above all types?
> 
> No. -webkit-textfield-decoration-container is used only in type=number and type=search.

I see.
Comment 12 Takashi Sakamoto 2012-11-12 23:40:37 PST
Created attachment 173834 [details]
Patch
Comment 13 Takashi Sakamoto 2012-11-12 23:42:03 PST
(In reply to comment #11)
> (In reply to comment #10)
> > (From update of attachment 173798 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=173798&action=review
> > 
> > >>> Source/WebCore/ChangeLog:11
> > >>> +        Test: fast/dom/HTMLInputElement/input-set-content-url-crash.html
> > >> 
> > >> Would you put the test as fast/forms/number/number-content-url-crash.html please?
> > >> Also, this bug should happen with <input type=search>. We had better have the same test for type=search.
> > > 
> > > So... I know the following input types inherit from class TextFieldInputType:
> > > - TextInputType
> > > - URLInputType
> > > - EmailInputType
> > > - SearchInputType
> > > - PasswordInputType
> > > - TelephoneInputType
> > > - NumberInputType
> > > - BaseDateAndTimeInputType
> > > 
> > > We have to add the same test for above all types?
> > 
> > No. -webkit-textfield-decoration-container is used only in type=number and type=search.

Thanks.

> I see.

I added number-content-url-crash.html and search-content-url-crash.html instead of input-set-content-url-crash.html.

Best regards,
Takashi Sakamoto
Comment 14 Kent Tamura 2012-11-12 23:52:33 PST
Comment on attachment 173834 [details]
Patch

ok
Comment 15 WebKit Review Bot 2012-11-13 00:24:22 PST
Comment on attachment 173834 [details]
Patch

Clearing flags on attachment: 173834

Committed r134377: <http://trac.webkit.org/changeset/134377>
Comment 16 WebKit Review Bot 2012-11-13 00:24:26 PST
All reviewed patches have been landed.  Closing bug.
Comment 17 Dimitri Glazkov (Google) 2012-11-13 16:34:11 PST
Reverted r134377 for reason:

Caused a mysterious Android Clang build failure, needs investigation before landing again.

Committed r134506: <http://trac.webkit.org/changeset/134506>
Comment 18 Dimitri Glazkov (Google) 2012-11-13 16:36:18 PST
This caused a weird breakage upstream:

http://build.chromium.org/p/chromium.linux/builders/Android%20Clang%20Builder%20%28dbg%29/builds/1281/steps/compile/logs/stdio
Comment 19 Kent Tamura 2012-11-13 16:40:18 PST
Was it fixed by https://bugs.webkit.org/show_bug.cgi?id=102108 ?
Comment 20 Dimitri Glazkov (Google) 2012-11-13 17:15:49 PST
Doh!
Can you guys re-land the patch?
Comment 21 Eric Seidel (no email) 2012-11-13 17:34:08 PST
There is no real need for these two tests to be separate. :)  But that also shouldn't stand in the way of this patch (re-)landing.
Comment 22 Takashi Sakamoto 2012-11-13 18:10:50 PST
Sorry, Dimitri.
Thank you, Kent-san.

I will re-land the patch.

Best regards,
Takashi Sakamoto
Comment 23 Takashi Sakamoto 2012-11-13 18:11:40 PST
Created attachment 174046 [details]
Patch for landing
Comment 24 WebKit Review Bot 2012-11-14 02:47:47 PST
Comment on attachment 174046 [details]
Patch for landing

Clearing flags on attachment: 174046

Committed r134584: <http://trac.webkit.org/changeset/134584>
Comment 25 WebKit Review Bot 2012-11-14 02:47:52 PST
All reviewed patches have been landed.  Closing bug.