[no subject]



-----Original Message-----
From: Reid Spencer [mailto:reid x10sys com]
Sent: Sunday, March 28, 2004 2:19 PM
To: xml gnome org
Subject: Re: [xml] Need help: My program trying to free


I've seen a similar problem but it is based on incorrect usage of the way the xmlTextReader is allocated.

If you allocate your text reader with xmlNewTextReaderFilename and don't call xmlTextReaderSetup then we you 
call xmlFreeTextReader you'll get a core dump when it tries to dereference one of the fields inside the 
xmlTextReader structure. The correct way to create the xmlTextReader is to use xmlReaderForFile.

Reid.

On Sun, 2004-03-28 at 03:17, Daniel Veillard wrote: 

On Sat, Mar 27, 2004 at 09:16:13PM -0500, Jones, Mark A (Mark) wrote:

I'm getting a core dump after calling xmlFreeTextReader(reader).  Has anyone seen a problem like this 
before?  I show the piece of code that is dropping the core along with a few stack frames (gdb) from the 
core file.   Any insight would be much appreciated.

[..]

        type = processNode(reader);                                                                       

        if ( type == DETAILS || type == DETAIL )       

            ret = xmlTextReaderNext(reader);           

        else                                           

            ret = xmlTextReaderRead(reader);           

    }                                                          

    xmlFreeTextReader(reader);                         



  Without a way to reproduce the problem, I don't see what might be going

wrong. maybe processNode() made a free error, maybe your program made a free

error, destroying the allocator data and making xmlFreeTextReader() fail.

Use valgrind or other memory debugging tool.



Daniel


------_=_NextPart_001_01C41533.5AF5C2AC
Content-Type: text/html;
        charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dutf-8">


<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D262545301-29032004><FONT face=3DArial =
color=3D#0000ff=20
size=3D2>Reid,</FONT></SPAN></DIV>
<DIV><SPAN class=3D262545301-29032004><FONT face=3DArial =
color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D262545301-29032004><FONT face=3DArial =
color=3D#0000ff size=3D2>I'm=20
actually parsing an incore XML document (not from a file).&nbsp; I use =
the&nbsp;=20
call "<FONT size=3D2>reader =3D xmlReaderForMemory (buf, size, NULL, =
NULL,=20
0);"&nbsp; to set up an xmlTextReaderPtr.&nbsp; buf points to the =
incore XML=20
document.&nbsp; I then use</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=3D262545301-29032004><FONT face=3DArial =
color=3D#0000ff size=3D2>the=20
call "<FONT size=3D2>ret =3D xmlTextReaderRead(reader);" to walk (in a=20
loop)&nbsp;through all the nodes in the document.&nbsp; This all works =
very=20
well, except at the end of walking through the nodes, I get a core =
trying to=20
free the space that reader points to.</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=3D262545301-29032004><FONT face=3DArial =
color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D262545301-29032004><FONT face=3DArial =
color=3D#0000ff size=3D2>From=20
the earlier gdb bactrace snippet and from Daniel's comment below, I'm =
thinking=20
that something weird is going on with the memory pointed to be =
reader.&nbsp;=20
I'll use gdb to watch for reads/writes to reader and strace to watch =
for=20
inadvertent system calls on reader&nbsp;(eg free before calling=20
xmlFreeTextReader)</FONT></SPAN></DIV>
<DIV><SPAN class=3D262545301-29032004><FONT face=3DArial =
color=3D#0000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D262545301-29032004><FONT face=3DArial =
color=3D#0000ff size=3D2>M.=20
Jones</FONT></SPAN></DIV>
<BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
  <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B> Reid Spencer=20
  [mailto:reid x10sys com]<BR><B>Sent:</B> Sunday, March 28, 2004 2:19=20
  PM<BR><B>To:</B> xml gnome org<BR><B>Subject:</B> Re: [xml] Need =
help: My=20
  program trying to free<BR><BR></FONT></DIV>I've seen a similar =
problem but it=20
  is based on incorrect usage of the way the xmlTextReader is=20
  allocated.<BR><BR>If you allocate your text reader with=20
  xmlNewTextReaderFilename and don't call xmlTextReaderSetup then we =
you call=20
  xmlFreeTextReader you'll get a core dump when it tries to dereference =
one of=20
  the fields inside the xmlTextReader structure. The correct way to =
create the=20
  xmlTextReader is to use xmlReaderForFile.<BR><BR>Reid.<BR><BR>On Sun, =

  2004-03-28 at 03:17, Daniel Veillard wrote:=20
  <BLOCKQUOTE TYPE=3D"CITE"><PRE><FONT color=3D#301fe4><I>On Sat, Mar =
27, 2004 at 09:16:13PM -0500, Jones, Mark A (Mark) wrote:
&gt; I'm getting a core dump after calling xmlFreeTextReader(reader).  =
Has anyone seen a problem like this before?  I show the piece of code =
that is dropping the core along with a few stack frames (gdb) from the =
core file.   Any insight would be much appreciated.
[..]
&gt;         type =3D processNode(reader);                              =
                                        =20
&gt;         if ( type =3D=3D DETAILS || type =3D=3D DETAIL )      =20
&gt;             ret =3D xmlTextReaderNext(reader);          =20
&gt;         else                                          =20
&gt;             ret =3D xmlTextReaderRead(reader);          =20
&gt;     }                                                         =20
&gt;     xmlFreeTextReader(reader);                        =20

  Without a way to reproduce the problem, I don't see what might be =
going
wrong. maybe processNode() made a free error, maybe your program made a =
free
error, destroying the allocator data and making xmlFreeTextReader() =
fail.
Use valgrind or other memory debugging tool.

Daniel</I></FONT></PRE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C41533.5AF5C2AC--



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]