<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>153462</bug_id>
          
          <creation_ts>2016-01-25 16:13:15 -0800</creation_ts>
          <short_desc>CSSGrammar.y:1742.31-34: warning: unused value: $3</short_desc>
          <delta_ts>2016-01-27 19:20:48 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>CSS</component>
          <version>Other</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Catanzaro">mcatanzaro</reporter>
          <assigned_to name="Michael Catanzaro">mcatanzaro</assigned_to>
          <cc>achristensen</cc>
    
    <cc>commit-queue</cc>
    
    <cc>hyatt</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>ossy</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1158584</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-01-25 16:13:15 -0800</bug_when>
    <thetext>I&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1158651</commentid>
    <comment_count>1</comment_count>
      <attachid>269835</attachid>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-01-25 18:36:37 -0800</bug_when>
    <thetext>Created attachment 269835
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1158654</commentid>
    <comment_count>2</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2016-01-25 18:38:31 -0800</bug_when>
    <thetext>When did this start?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1158661</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-01-25 18:55:02 -0800</bug_when>
    <thetext>(In reply to comment #2)
&gt; When did this start?

Several months ago. It&apos;s not the only build warning we have, and the last time I looked I wasn&apos;t sure what to do with it.

I think the warning is only available in newer versions of bison than you&apos;d have easy access to.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1158664</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-01-25 18:59:21 -0800</bug_when>
    <thetext>It was introduced in r191128, so I&apos;ll CC David for review.

P.S. My rationale for CCing you, Alex, was that I once heard you say &quot;bison.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1158701</commentid>
    <comment_count>5</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2016-01-25 21:43:38 -0800</bug_when>
    <thetext>http://trac.webkit.org/changeset/191128/trunk/Source/WebCore/css/CSSGrammar.y.in definitely added some new&apos;s without a corresponding delete.  I&apos;d prefer to have someone double check this, though.  Hyatt?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1158723</commentid>
    <comment_count>6</comment_count>
    <who name="Csaba Osztrogonác">ossy</who>
    <bug_when>2016-01-25 23:13:35 -0800</bug_when>
    <thetext>*** Bug 150325 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1158931</commentid>
    <comment_count>7</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2016-01-26 12:35:46 -0800</bug_when>
    <thetext>This code is definitely run by fast/css/variables/test-suite/036.html and fast/css/variables/test-suite/068.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1158937</commentid>
    <comment_count>8</comment_count>
      <attachid>269835</attachid>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2016-01-26 12:42:13 -0800</bug_when>
    <thetext>Comment on attachment 269835
Patch

Running those tests with guardmalloc passes, so I&apos;m going to say r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1158942</commentid>
    <comment_count>9</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2016-01-26 12:50:49 -0800</bug_when>
    <thetext>(In reply to comment #5)
&gt; http://trac.webkit.org/changeset/191128/trunk/Source/WebCore/css/CSSGrammar.
&gt; y.in definitely added some new&apos;s without a corresponding delete.
And this delete does not correspond to the new&apos;s added in that patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1158967</commentid>
    <comment_count>10</comment_count>
      <attachid>269835</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2016-01-26 13:12:40 -0800</bug_when>
    <thetext>Comment on attachment 269835
Patch

Clearing flags on attachment: 269835

Committed r195612: &lt;http://trac.webkit.org/changeset/195612&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1158968</commentid>
    <comment_count>11</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2016-01-26 13:12:44 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1159226</commentid>
    <comment_count>12</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2016-01-26 23:39:57 -0800</bug_when>
    <thetext>(In reply to comment #9)
&gt; (In reply to comment #5)
&gt; &gt; http://trac.webkit.org/changeset/191128/trunk/Source/WebCore/css/CSSGrammar.
&gt; &gt; y.in definitely added some new&apos;s without a corresponding delete.
&gt; And this delete does not correspond to the new&apos;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&apos;m wrong.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1159313</commentid>
    <comment_count>13</comment_count>
      <attachid>269835</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2016-01-27 10:19:44 -0800</bug_when>
    <thetext>Comment on attachment 269835
Patch

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

&gt; Source/WebCore/ChangeLog:12
&gt; +        &quot;Right-hand side symbols of a rule that explicitly triggers a syntax error via YYERROR are
&gt; +        not discarded automatically. As a rule of thumb, destructors are invoked only when user
&gt; +        actions cannot manage the memory.&quot;

Sounds like we might have leaks in other rules that invoke YYERROR; did you check those over?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1159328</commentid>
    <comment_count>14</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2016-01-27 10:43:59 -0800</bug_when>
    <thetext>(In reply to comment #13)
&gt; Sounds like we might have leaks in other rules that invoke YYERROR; did you
&gt; check those over?
I looked them over, and I&apos;m pretty sure there isn&apos;t one we&apos;re missing a delete before.  Most of them would have a similar warning, and the ones that wouldn&apos;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&apos;s a unique_ptr anyways).  Maybe we should use unique_ptrs everywhere in the parser instead of new to avoid future problems like this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1159376</commentid>
    <comment_count>15</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-01-27 12:43:42 -0800</bug_when>
    <thetext>(In reply to comment #13)
&gt; Sounds like we might have leaks in other rules that invoke YYERROR; did you
&gt; check those over?

I think the other YYERROR cases are fine; there are not that many.

(In reply to comment #12)
&gt; This delete corresponds with the following new in line 1668 in the
&gt; definition of valid_expr:
&gt; $$ = new CSSParserValueList;
&gt; 
&gt; Correct me if I&apos;m wrong.

I am not sure whether it&apos;s guaranteed to come from there; grammars are hard and I don&apos;t really want to try to understand this one. What&apos;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)
&gt; I looked them over, and I&apos;m pretty sure there isn&apos;t one we&apos;re missing a
&gt; delete before.  Most of them would have a similar warning, and the ones that
&gt; wouldn&apos;t (because $1, $2, etc. are used somewhere else) have entries like
&gt; IDENT (which I think is a string) or a nested_selector_list that is verified
&gt; to be nullptr (and it&apos;s a unique_ptr anyways).  Maybe we should use
&gt; unique_ptrs everywhere in the parser instead of new to avoid future problems
&gt; 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&apos;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&apos;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&apos;s.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1159379</commentid>
    <comment_count>16</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2016-01-27 12:47:45 -0800</bug_when>
    <thetext>I think the right solution is to not use bison.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1159575</commentid>
    <comment_count>17</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-01-27 19:20:48 -0800</bug_when>
    <thetext>I&apos;m a fan of bison. *Shrug*

I looked up unions in &quot;The C++ Programming Language&quot; and the answer is: yes you can use class types in unions now, but it&apos;s not going to work for std::unique_ptr because it requires no custom contructor, destructor, or copy/move assignment operators.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>269835</attachid>
            <date>2016-01-25 18:36:37 -0800</date>
            <delta_ts>2016-01-26 13:12:40 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-153462-20160125203610.patch</filename>
            <type>text/plain</type>
            <size>1506</size>
            <attacher name="Michael Catanzaro">mcatanzaro</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTk1NTU5CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggOTA3YmU0ZDkyMmFkM2Jj
ZTc4NzVmNTkzODhiMzkwM2QyN2JhYjY2Ni4uNTkzOTg5YWUxMTBjNDZjNjBmM2EyZmI4Y2UxZTkx
YWRiOWRkZDYxYyAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDIwIEBACisyMDE2LTAxLTI1ICBNaWNo
YWVsIENhdGFuemFybyAgPG1jYXRhbnphcm9AaWdhbGlhLmNvbT4KKworICAgICAgICBDU1NHcmFt
bWFyLnk6MTc0Mi4zMS0zNDogd2FybmluZzogdW51c2VkIHZhbHVlOiAkMworICAgICAgICBodHRw
czovL2J1Z3Mud2Via2l0Lm9y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