Bug 140993 - REGRESSION (r173698): Leaks of selector lists in CSS parsing
Summary: REGRESSION (r173698): Leaks of selector lists in CSS parsing
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Darin Adler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-28 00:53 PST by Darin Adler
Modified: 2015-01-28 18:18 PST (History)
5 users (show)

See Also:


Attachments
Patch (4.95 KB, patch)
2015-01-28 00:54 PST, Darin Adler
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews100 for mac-mavericks (617.54 KB, application/zip)
2015-01-28 01:45 PST, Build Bot
no flags Details
Archive of layout-test-results from ews106 for mac-mavericks-wk2 (745.34 KB, application/zip)
2015-01-28 01:51 PST, Build Bot
no flags Details
Patch (8.60 KB, patch)
2015-01-28 08:49 PST, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (8.60 KB, patch)
2015-01-28 08:50 PST, Darin Adler
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2015-01-28 00:53:26 PST
REGRESSION (r174245): Leaks of selector lists in CSS parsing
Comment 1 Darin Adler 2015-01-28 00:54:18 PST
Created attachment 245524 [details]
Patch
Comment 2 Build Bot 2015-01-28 01:44:59 PST
Comment on attachment 245524 [details]
Patch

Attachment 245524 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/4614272839581696

New failing tests:
fast/css/parsing-css-nth-child-of-3.html
fast/css/parsing-css-nth-child-of-4.html
fast/css/parsing-css-nth-last-child-of-3.html
fast/css/parsing-css-nth-last-child-of-4.html
Comment 3 Build Bot 2015-01-28 01:45:01 PST
Created attachment 245526 [details]
Archive of layout-test-results from ews100 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 4 Build Bot 2015-01-28 01:51:25 PST
Comment on attachment 245524 [details]
Patch

Attachment 245524 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/4873772884557824

New failing tests:
fast/css/parsing-css-nth-child-of-3.html
fast/css/parsing-css-nth-last-child-of-4.html
fast/css/parsing-css-nth-last-child-of-3.html
fast/css/parsing-css-nth-child-of-4.html
Comment 5 Build Bot 2015-01-28 01:51:27 PST
Created attachment 245527 [details]
Archive of layout-test-results from ews106 for mac-mavericks-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews106  Port: mac-mavericks-wk2  Platform: Mac OS X 10.9.5
Comment 6 Darin Adler 2015-01-28 08:49:45 PST
Created attachment 245546 [details]
Patch
Comment 7 Darin Adler 2015-01-28 08:50:25 PST
Created attachment 245547 [details]
Patch
Comment 8 Darin Adler 2015-01-28 08:51:19 PST
The magic invalidSelectorList value made this much harder than I expected. This is really messy, and we should look for a better solution eventually, but I think my latest patch does correctly fix the problem.
Comment 9 WebKit Commit Bot 2015-01-28 09:50:01 PST
Comment on attachment 245547 [details]
Patch

Clearing flags on attachment: 245547

Committed r179258: <http://trac.webkit.org/changeset/179258>
Comment 10 WebKit Commit Bot 2015-01-28 09:50:05 PST
All reviewed patches have been landed.  Closing bug.
Comment 11 Benjamin Poulain 2015-01-28 15:17:57 PST
Comment on attachment 245547 [details]
Patch

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

> Source/WebCore/css/CSSGrammar.y.in:1509
> +        if ($4 != invalidSelectorVector) {

I don't understand this check. An invalid :not() should have a null selector list, not an invalid one.
Comment 12 Darin Adler 2015-01-28 16:35:59 PST
Comment on attachment 245547 [details]
Patch

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

>> Source/WebCore/css/CSSGrammar.y.in:1509
>> +        if ($4 != invalidSelectorVector) {
> 
> I don't understand this check. An invalid :not() should have a null selector list, not an invalid one.

You’re right. This check isn’t needed. Sorry! Feel free to remove it.

I’d like to eventually follow this up with some more elegant scheme. I feel like the nth_selector_ending part of this is even more of a tightrope walk than the already-tricky lifetime management in this parser. Maybe we can require a newer version of yacc/bison and use fancier %union that works with C++ objects? Or find some other way to make this a little more foolproof. Maybe we should generate the parser with a completely different technology rather than yacc?
Comment 13 Benjamin Poulain 2015-01-28 18:18:08 PST
(In reply to comment #12)
> Comment on attachment 245547 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=245547&action=review
> 
> >> Source/WebCore/css/CSSGrammar.y.in:1509
> >> +        if ($4 != invalidSelectorVector) {
> > 
> > I don't understand this check. An invalid :not() should have a null selector list, not an invalid one.
> 
> You’re right. This check isn’t needed. Sorry! Feel free to remove it.
> 
> I’d like to eventually follow this up with some more elegant scheme. I feel
> like the nth_selector_ending part of this is even more of a tightrope walk
> than the already-tricky lifetime management in this parser. Maybe we can
> require a newer version of yacc/bison and use fancier %union that works with
> C++ objects? Or find some other way to make this a little more foolproof.
> Maybe we should generate the parser with a completely different technology
> rather than yacc?

"nth_selector_ending" was not my favorite option. I wanted to separate the two :nth-child() at the "pseudo" level but bison refused to shift that for an unknown reason.

Modern bison supports real LR(1) in addition LARL. That would simplify a bunch of stuff but LR(1) also create giant state machines so it may be terrible for performance.

Personally, I would like us to use an hybrid LL parser for various reasons. Google is writing a new CSS parser for blink, I am curious to see what they do.