WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
153462
CSSGrammar.y:1742.31-34: warning: unused value: $3
https://bugs.webkit.org/show_bug.cgi?id=153462
Summary
CSSGrammar.y:1742.31-34: warning: unused value: $3
Michael Catanzaro
Reported
2016-01-25 16:13:15 PST
I've been ignoring this bison warning for a while now: [620/5167] Generating ../../DerivedSou.../DerivedSources/WebCore/CSSGrammar.cpp /home/mcatanzaro/src/WebKit/WebKitBuild/GNOME/DerivedSources/WebCore/CSSGrammar.y:1742.31-34: warning: unused value: $3 [-Wother] | VARFUNCTION maybe_space expr closing_parenthesis { ^^^^ It means we are leaking the CSSParserValueList associated with that expr.
Attachments
Patch
(1.47 KB, patch)
2016-01-25 18:36 PST
,
Michael Catanzaro
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Michael Catanzaro
Comment 1
2016-01-25 18:36:37 PST
Created
attachment 269835
[details]
Patch
Alex Christensen
Comment 2
2016-01-25 18:38:31 PST
When did this start?
Michael Catanzaro
Comment 3
2016-01-25 18:55:02 PST
(In reply to
comment #2
)
> When did this start?
Several months ago. It's not the only build warning we have, and the last time I looked I wasn't sure what to do with it. I think the warning is only available in newer versions of bison than you'd have easy access to.
Michael Catanzaro
Comment 4
2016-01-25 18:59:21 PST
It was introduced in
r191128
, so I'll CC David for review. P.S. My rationale for CCing you, Alex, was that I once heard you say "bison."
Alex Christensen
Comment 5
2016-01-25 21:43:38 PST
http://trac.webkit.org/changeset/191128/trunk/Source/WebCore/css/CSSGrammar.y.in
definitely added some new's without a corresponding delete. I'd prefer to have someone double check this, though. Hyatt?
Csaba Osztrogonác
Comment 6
2016-01-25 23:13:35 PST
***
Bug 150325
has been marked as a duplicate of this bug. ***
Alex Christensen
Comment 7
2016-01-26 12:35:46 PST
This code is definitely run by fast/css/variables/test-suite/036.html and fast/css/variables/test-suite/068.html
Alex Christensen
Comment 8
2016-01-26 12:42:13 PST
Comment on
attachment 269835
[details]
Patch Running those tests with guardmalloc passes, so I'm going to say r=me
Alex Christensen
Comment 9
2016-01-26 12:50:49 PST
(In reply to
comment #5
)
>
http://trac.webkit.org/changeset/191128/trunk/Source/WebCore/css/CSSGrammar
. > y.in definitely added some new's without a corresponding delete.
And this delete does not correspond to the new's added in that patch.
WebKit Commit Bot
Comment 10
2016-01-26 13:12:40 PST
Comment on
attachment 269835
[details]
Patch Clearing flags on attachment: 269835 Committed
r195612
: <
http://trac.webkit.org/changeset/195612
>
WebKit Commit Bot
Comment 11
2016-01-26 13:12:44 PST
All reviewed patches have been landed. Closing bug.
Alex Christensen
Comment 12
2016-01-26 23:39:57 PST
(In reply to
comment #9
)
> (In reply to
comment #5
) > >
http://trac.webkit.org/changeset/191128/trunk/Source/WebCore/css/CSSGrammar
. > > y.in definitely added some new's without a corresponding delete. > And this delete does not correspond to the new's added in that patch.
This delete corresponds with the following new in line 1668 in the definition of valid_expr: $$ = new CSSParserValueList; Correct me if I'm wrong.
Darin Adler
Comment 13
2016-01-27 10:19:44 PST
Comment on
attachment 269835
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=269835&action=review
> Source/WebCore/ChangeLog:12 > + "Right-hand side symbols of a rule that explicitly triggers a syntax error via YYERROR are > + not discarded automatically. As a rule of thumb, destructors are invoked only when user > + actions cannot manage the memory."
Sounds like we might have leaks in other rules that invoke YYERROR; did you check those over?
Alex Christensen
Comment 14
2016-01-27 10:43:59 PST
(In reply to
comment #13
)
> Sounds like we might have leaks in other rules that invoke YYERROR; did you > check those over?
I looked them over, and I'm pretty sure there isn't one we're missing a delete before. Most of them would have a similar warning, and the ones that wouldn't (because $1, $2, etc. are used somewhere else) have entries like IDENT (which I think is a string) or a nested_selector_list that is verified to be nullptr (and it's a unique_ptr anyways). Maybe we should use unique_ptrs everywhere in the parser instead of new to avoid future problems like this.
Michael Catanzaro
Comment 15
2016-01-27 12:43:42 PST
(In reply to
comment #13
)
> Sounds like we might have leaks in other rules that invoke YYERROR; did you > check those over?
I think the other YYERROR cases are fine; there are not that many. (In reply to
comment #12
)
> This delete corresponds with the following new in line 1668 in the > definition of valid_expr: > $$ = new CSSParserValueList; > > Correct me if I'm wrong.
I am not sure whether it's guaranteed to come from there; grammars are hard and I don't really want to try to understand this one. What's important is that expr has a semantic value of type CSSParserValueList*, so each rule that uses expr needs to either delete it or percolate it up by assigning it to $$, else it will be leaked. (In reply to
comment #14
)
> I looked them over, and I'm pretty sure there isn't one we're missing a > delete before. Most of them would have a similar warning, and the ones that > wouldn't (because $1, $2, etc. are used somewhere else) have entries like > IDENT (which I think is a string) or a nested_selector_list that is verified > to be nullptr (and it's a unique_ptr anyways). Maybe we should use > unique_ptrs everywhere in the parser instead of new to avoid future problems > like this.
This would make the bison parser more robust, to be sure. (I am worried that the current grammar might be leaking values in cases where they are actually used, which would suppress the warning. But maybe it is fine; I don't plan to investigate further.) There might be an easy way to use std::unique_ptr. I have heard that it might be possible in C++ 11 to use class instances in unions (and have them be properly destructed), but I am having trouble finding reliable info with a quick Internet search. If that's true, and it works in GCC/Clang/MSVCC, then we could use std::unique_ptr in the %union declaration at the top of the file, which would allow us to get some safety without switching to a different skeleton. I am not sure if it is possible to safely use class types in unions, though; if not, we are stuck with error-prone new and delete. There is an alternative, which is to switch to the experimental C++ skeleton. The new skeleton allows storing C++ objects as semantic values, rather than relying on a union. Unfortunately, it is only available in modern versions of bison. I believe you would have internal political difficulties to do this, due to the GPLv3+ license, although the same non-infectious license exception applies to the generated code as always (so we can safely use it in WebKit without infecting our license). I hesitate to recommend this, though, as the C++ skeleton is still experimental; some serious bugs in it that I discovered were fixed not so long ago, and my grammar was for a school project, much simpler than WebKit's.
Alex Christensen
Comment 16
2016-01-27 12:47:45 PST
I think the right solution is to not use bison.
Michael Catanzaro
Comment 17
2016-01-27 19:20:48 PST
I'm a fan of bison. *Shrug* I looked up unions in "The C++ Programming Language" and the answer is: yes you can use class types in unions now, but it's not going to work for std::unique_ptr because it requires no custom contructor, destructor, or copy/move assignment operators.
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