<?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>150724</bug_id>
          
          <creation_ts>2015-10-30 11:52:31 -0700</creation_ts>
          <short_desc>CSSParserVariable leaks seen on leaks bots</short_desc>
          <delta_ts>2015-10-30 16:19:21 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</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>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Joseph Pecoraro">joepeck</reporter>
          <assigned_to name="Joseph Pecoraro">joepeck</assigned_to>
          <cc>ap</cc>
    
    <cc>commit-queue</cc>
    
    <cc>darin</cc>
    
    <cc>hyatt</cc>
    
    <cc>joepeck</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1137906</commentid>
    <comment_count>0</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-10-30 11:52:31 -0700</bug_when>
    <thetext>* SUMMARY
CSSParserVariable leaks seen on leaks bots.
https://build.webkit.org/builders/Apple%20Yosemite%20%28Leaks%29/builds/3581

* LEAK (allocation trace)
Call stack: [thread 0x11c62f300]: 
    | 0x2 
    | start 
    | main DumpRenderTreeMain.mm:30 
    | DumpRenderTreeMain(int, char const**) DumpRenderTree.mm:1430 
    | dumpRenderTree(int, char const**) DumpRenderTree.mm:1295 
    | runTestingServerLoop() DumpRenderTree.mm:1186 
    | runTest(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;) DumpRenderTree.mm:2036 
    | CFRunLoopRunSpecific 
    | __CFRunLoopRun 
    | __CFRunLoopDoSources0 
    | __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ 
    | MultiplexerSource::_perform(void*) 
    | MultiplexerSource::perform() 
    | RunloopBlockContext::perform() 
    | CFArrayApplyFunction 
    | RunloopBlockContext::_invoke_block(void const*, void*) 
    | ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 
    | ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke 
    | -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] 
    | -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] 
    | __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke 
    | -[WebCoreResourceHandleAsDelegate connectionDidFinishLoading:] WebCoreResourceHandleAsDelegate.mm:258 
    | WebCore::ResourceLoader::didFinishLoading(WebCore::ResourceHandle*, double) ResourceLoader.cpp:639 
    | WebCore::SubresourceLoader::didFinishLoading(double) SubresourceLoader.cpp:374 
    | WebCore::CachedCSSStyleSheet::finishLoading(WebCore::SharedBuffer*) CachedCSSStyleSheet.cpp:101 
    | WebCore::CachedCSSStyleSheet::checkNotify() CachedCSSStyleSheet.cpp:113 
    | non-virtual thunk to WebCore::HTMLLinkElement::setCSSStyleSheet(WTF::String const&amp;, WebCore::URL const&amp;, WTF::String const&amp;, WebCore::CachedCSSStyleSheet const*) HTMLLinkElement.cpp:359 
    | WebCore::HTMLLinkElement::setCSSStyleSheet(WTF::String const&amp;, WebCore::URL const&amp;, WTF::String const&amp;, WebCore::CachedCSSStyleSheet const*) HTMLLinkElement.cpp:351 
    | WebCore::StyleSheetContents::parseAuthorStyleSheet(WebCore::CachedCSSStyleSheet const*, WebCore::SecurityOrigin const*) StyleSheetContents.cpp:317 
    | WebCore::CSSParser::parseSheet(WebCore::StyleSheetContents*, WTF::String const&amp;, WTF::TextPosition const&amp;, WTF::Vector&lt;WTF::RefPtr&lt;WebCore::CSSRuleSourceData&gt;, 0ul, WTF::CrashOnOverflow, 16ul&gt;*, bool) CSSParser.cpp:462 
    | cssyyparse(WebCore::CSSParser*) .CSSGrammar.y:1743 
    | WebCore::CSSParserVariable::operator new(unsigned long) CSSParserValues.h:193 
    | WTF::fastMalloc(unsigned long) FastMalloc.cpp:193 
    | bmalloc::api::malloc(unsigned long) bmalloc.h:43 
    | bmalloc::Cache::allocate(unsigned long) Cache.h:79 
    | bmalloc::Allocator::allocate(unsigned long) Allocator.h:86 
    | bmalloc::Allocator::allocateSlowCase(unsigned long) Allocator.cpp:242 
    | malloc 
    | malloc_zone_malloc 

* NOTES

CSSGrammar.y.in

&gt; variable_function:
&gt;     VARFUNCTION maybe_space CUSTOM_PROPERTY maybe_space closing_parenthesis {
&gt;         CSSParserVariable* var = new CSSParserVariable;
&gt;         var-&gt;name = $3;
&gt;         var-&gt;args = nullptr;
&gt;         $$.id = CSSValueInvalid;
&gt;         $$.unit = CSSParserValue::Variable;
&gt;         $$.variable = var;
&gt;     }
&gt;    ...

It looks like `variable_function` has some destroy() method:

&gt; %type &lt;value&gt; calc_function function variable_function min_or_max_function term
&gt; %destructor { destroy($$); } calc_function function variable_function min_or_max_function term

Maybe this destroy function should be deleting `.variable` in the new case:

&gt; void destroy(const CSSParserValue&amp; value)
&gt; {
&gt;     if (value.unit == CSSParserValue::Function)
&gt;         delete value.function;
&gt;     else if (value.unit == CSSParserValue::ValueList)
&gt;         delete value.valueList;
&gt; }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1137914</commentid>
    <comment_count>1</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-10-30 12:02:31 -0700</bug_when>
    <thetext>* STEPS TO REPRODUCE
shell&gt; run-webkit-tests --leaks -1 fast/css/variables</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1137920</commentid>
    <comment_count>2</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-10-30 12:18:55 -0700</bug_when>
    <thetext>This gets most of the leaks, there are still others. I&apos;ll give some time to tracking them otherwise I&apos;ll just put this patch up.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1137923</commentid>
    <comment_count>3</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-10-30 12:28:19 -0700</bug_when>
    <thetext>There is a CSSParserValueList leak, which I suspect is happening from:

    CSSValueList::buildParserValueSubstitutingVariables
    CSSValueList::buildParserValueListSubstitutingVariables

They call each other but in the error cases I don&apos;t think the CSSParserValueList created by buildParserValueSubstitutingVariables gets destroyed. I&apos;ll file a separate bug about this, since it is non-trivial for me but probably easy for those familiar with what this code is doing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1137930</commentid>
    <comment_count>4</comment_count>
      <attachid>264410</attachid>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-10-30 12:37:02 -0700</bug_when>
    <thetext>Created attachment 264410
[PATCH] Proposed Fix</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1138018</commentid>
    <comment_count>5</comment_count>
      <attachid>264410</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2015-10-30 16:19:17 -0700</bug_when>
    <thetext>Comment on attachment 264410
[PATCH] Proposed Fix

Clearing flags on attachment: 264410

Committed r191825: &lt;http://trac.webkit.org/changeset/191825&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1138019</commentid>
    <comment_count>6</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2015-10-30 16:19:21 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>264410</attachid>
            <date>2015-10-30 12:37:02 -0700</date>
            <delta_ts>2015-10-30 16:19:17 -0700</delta_ts>
            <desc>[PATCH] Proposed Fix</desc>
            <filename>variables-cleanup.patch</filename>
            <type>text/plain</type>
            <size>1205</size>
            <attacher name="Joseph Pecoraro">joepeck</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZyBiL1NvdXJjZS9XZWJDb3JlL0No
YW5nZUxvZwppbmRleCAzNGVlNjMwLi43YWU5ZjlmIDEwMDY0NAotLS0gYS9Tb3VyY2UvV2ViQ29y
ZS9DaGFuZ2VMb2cKKysrIGIvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCkBAIC0xLDUgKzEsMTYg
QEAKIDIwMTUtMTAtMzAgIEpvc2VwaCBQZWNvcmFybyAgPHBlY29yYXJvQGFwcGxlLmNvbT4KIAor
ICAgICAgICBDU1NQYXJzZXJWYXJpYWJsZSBsZWFrcyBzZWVuIG9uIGxlYWtzIGJvdHMKKyAgICAg
ICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTE1MDcyNAorCisgICAg
ICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAgICogY3NzL0NTU1BhcnNl
clZhbHVlcy5jcHA6CisgICAgICAgIChXZWJDb3JlOjpkZXN0cm95KToKKyAgICAgICAgQ2xlYW51
cCB2YXJpYWJsZSBDU1NQYXJzZXJWYWx1ZXMuCisKKzIwMTUtMTAtMzAgIEpvc2VwaCBQZWNvcmFy
byAgPHBlY29yYXJvQGFwcGxlLmNvbT4KKwogICAgICAgICBNaW5vciBDR0NvbG9yIGxlYWtzIHNl
ZW4gb24gYm90cyBhbGxvY2F0ZWQgaW4gV2ViU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