<?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>4796</bug_id>
          
          <creation_ts>2005-09-01 15:17:19 -0700</creation_ts>
          <short_desc>leaks of NodeImpl called from HTMLParser::textCreateErrorCheck, seen running webkit tests</short_desc>
          <delta_ts>2005-09-06 19:35:17 -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>WebKit Misc.</component>
          <version>420+</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</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="John Sullivan">sullivan</reporter>
          <assigned_to name="Darin Adler">darin</assigned_to>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>18198</commentid>
    <comment_count>0</comment_count>
    <who name="John Sullivan">sullivan</who>
    <bug_when>2005-09-01 15:17:19 -0700</bug_when>
    <thetext>This bug is also in Radar as &lt;rdar://4232812&gt;

This is split off from 4665. This is one of the many leaks found with these steps:

1. Build a development build of tip-of-tree WebKit
2. use run-webkit-tests --leaks

Leak: 0x1d5ac780  size=48	
	0x013f85b0 0x00000000 0x00000000 0x1d5d1990 	.?...........]..
	0x00000000 0x00000000 0x00000000 0x00000000 	................
	0x00000000 0x00000000 0x1f30fc90 0x00000000 	.........0......
	Call stack: [thread 239f]: | 0x0 | start | _start | main | dumpRenderTree | -[NSRunLoop 
runMode:beforeDate:] | CFRunLoopRunSpecific | __CFRunLoopRun | __CFRunLoopDoSources0 | 
_sendCallbacks | -[NSURLConnection(NSURLConnectionInternal) _sendCallbacks] | -[NSURLConnection
(NSURLConnectionInternal) _sendDidReceiveDataCallback] | -[WebLoader 
connection:didReceiveData:lengthReceived:] | -[WebMainResourceLoader 
didReceiveData:lengthReceived:] | -[WebLoader didReceiveData:lengthReceived:] | -
[WebMainResourceLoader addData:] | -[WebDataSource(WebPrivate) _receivedData:] | -
[WebHTMLRepresentation receivedData:withDataSource:] | -[WebBridge 
receivedData:textEncodingName:] | -[WebCoreBridge addData:] | KWQKHTMLPart::addData(char const*, 
int) | KHTMLPart::write(char const*, int) | khtml::HTMLTokenizer::write(khtml::TokenizerString const&amp;, 
bool) | khtml::HTMLTokenizer::processToken() | HTMLParser::parseToken(khtml::Token*) | 
HTMLParser::getNode(khtml::Token*) | HTMLParser::textCreateErrorCheck(khtml::Token*, 
DOM::NodeImpl*&amp;) | DOM::NodeImpl::operator new(unsigned long) | khtml::main_thread_malloc
(unsigned long) | malloc 

This leak occurred 4 times in the attachment in 4665

I still see this one today (most of the other leaks from 4665 have now been fixed).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18315</commentid>
    <comment_count>1</comment_count>
    <who name="Kurt Kohler">kohler</who>
    <bug_when>2005-09-02 22:27:52 -0700</bug_when>
    <thetext>(In reply to comment #0)
&gt; This bug is also in Radar as &lt;rdar://4232812&gt;
&gt; 
&gt; This is split off from 4665. This is one of the many leaks found with these steps:
&gt; 
&gt; 1. Build a development build of tip-of-tree WebKit
&gt; 2. use run-webkit-tests --leaks
&gt; 
&gt; Leak: 0x1d5ac780  size=48	
&gt; 	0x013f85b0 0x00000000 0x00000000 0x1d5d1990 	.?...........]..
&gt; 	0x00000000 0x00000000 0x00000000 0x00000000 	................
&gt; 	0x00000000 0x00000000 0x1f30fc90 0x00000000 	.........0......
&gt; 	Call stack: [thread 239f]: | 0x0 | start | _start | main | dumpRenderTree |
-[NSRunLoop 
&gt; runMode:beforeDate:] | CFRunLoopRunSpecific | __CFRunLoopRun |
__CFRunLoopDoSources0 | 
&gt; _sendCallbacks | -[NSURLConnection(NSURLConnectionInternal) _sendCallbacks] |
-[NSURLConnection
&gt; (NSURLConnectionInternal) _sendDidReceiveDataCallback] | -[WebLoader 
&gt; connection:didReceiveData:lengthReceived:] | -[WebMainResourceLoader 
&gt; didReceiveData:lengthReceived:] | -[WebLoader didReceiveData:lengthReceived:] | -
&gt; [WebMainResourceLoader addData:] | -[WebDataSource(WebPrivate) _receivedData:] | -
&gt; [WebHTMLRepresentation receivedData:withDataSource:] | -[WebBridge 
&gt; receivedData:textEncodingName:] | -[WebCoreBridge addData:] |
KWQKHTMLPart::addData(char const*, 
&gt; int) | KHTMLPart::write(char const*, int) |
khtml::HTMLTokenizer::write(khtml::TokenizerString const&amp;, 
&gt; bool) | khtml::HTMLTokenizer::processToken() |
HTMLParser::parseToken(khtml::Token*) | 
&gt; HTMLParser::getNode(khtml::Token*) |
HTMLParser::textCreateErrorCheck(khtml::Token*, 
&gt; DOM::NodeImpl*&amp;) | DOM::NodeImpl::operator new(unsigned long) |
khtml::main_thread_malloc
&gt; (unsigned long) | malloc 
&gt; 
&gt; This leak occurred 4 times in the attachment in 4665
&gt; 
&gt; I still see this one today (most of the other leaks from 4665 have now been
fixed).


  I&apos;ve been looking at that same one and I may see the problem. In
HTMLParser::getNode() &quot;result&quot; is potentially set twice. When it&apos;s set the
second time, I don&apos;t see any guarantee that you won&apos;t be overwriting a non-null
pointer. I think there should be a &quot;delete result&quot; just before the second time
&quot;result&quot; is set. I can submit a patch, but it seems pretty trivial (assuming I&apos;m
right!)

By the way, wouldn&apos;t it be more straightforward to have getNode return a
SmartPtr rather than converting the raw pointer after the (single) call to getNode?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18318</commentid>
    <comment_count>2</comment_count>
    <who name="Kurt Kohler">kohler</who>
    <bug_when>2005-09-02 23:49:01 -0700</bug_when>
    <thetext>Unfortunately the change I suggested doesn&apos;t fix the leak. Sorry.

I&apos;d still suggest an &quot;assert(!result)&quot; just before the assignment to result however.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18937</commentid>
    <comment_count>3</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2005-09-06 19:17:13 -0700</bug_when>
    <thetext>This function is where all text nodes are created while parsing.

I&apos;m pretty sure that this is the same leak I fixed in my fix for bug 4797.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18939</commentid>
    <comment_count>4</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2005-09-06 19:35:17 -0700</bug_when>
    <thetext>Checked in a fix that should fix the leak described in this bug, as well as two others. The three bugs are 
bug 4795, bug 4796, and bug 4797.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>