Re: [xml] Crash on xmlMalloc



On Thu, Sep 09, 2010 at 11:03:45AM +0200, IMS wrote:
Hi all,

I'm developing an application using the library libxml2.
It seams that all was ok but yesterday my application crashed for an unknown
reason.
I tried to debug and after some work I found that the line where my
application crash is the xmlMalloc in the xmlParserCtxtPtr !

I'm using the libxml2 version 2.7.6
I'm using the autotools

=> In the file configure.ac :
*# libxml2*
*PKG_CHECK_MODULES(LIBXMLDEPS, libxml-2.0 >= 2.6.8)*
*AC_SUBST(LIBXMLDEPS_CFLAGS)*

=> In the file makefile.am :
l*ibmxml_la_CPPFLAGS = -Iinclude $(LIBXMLDEPS_CFLAGS) -D_GNU_SOURCE*

This is the back-trace :

*** glibc detected *** /home/mine/buildSVNLocal/web/cgi/config_etat.cgi:
malloc(): memory corruption: 0x08052840 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(+0x6b591)[0x55f591]
/lib/tls/i686/cmov/libc.so.6(+0x6e395)[0x562395]
/lib/tls/i686/cmov/libc.so.6(__libc_malloc+0x5c)[0x563f9c]
/usr/lib/libxml2.so.2(xmlNewParserCtxt+0x29)[0x3a02d9]
/usr/lib/libxml2.so.2(xmlCreateMemoryParserCtxt+0x34)[0x3a3d94]
/usr/lib/libxml2.so.2(xmlSAXParseMemoryWithData+0x34)[0x3bae74]
/usr/lib/libxml2.so.2(xmlSAXParseMemory+0x2e)[0x3baf3e]
/usr/lib/libxml2.so.2(xmlParseMemory+0x28)[0x3baf98]
/home/mine/local/lib/libmxml.so.1(raw_parse_buffer+0x93)[0x15dd0a] //I call
here xmlParseMemory

This is the function :

xmlParserCtxtPtr xmlNewParserCtxt(void)
{
    xmlParserCtxtPtr ctxt;

    ctxt = (xmlParserCtxtPtr) xmlMalloc(sizeof(xmlParserCtxt));
    if (ctxt == NULL) {
              //<- Never see this line !!!
xmlErrMemory(NULL, "cannot allocate parser context\n");
return(NULL);
    }
    memset(ctxt, 0, sizeof(xmlParserCtxt));
    if (xmlInitParserCtxt(ctxt) < 0) {
        xmlFreeParserCtxt(ctxt);
return(NULL);
    }
    return(ctxt);
}

With a google search I saw some errors with xmlMalloc but not in the same
context that mine.
Do you have any ideas ? I need your help.

  Some of the code of the application is corrupting memory, it happen to
corrupt the memory allocation area managed by glibc, and glibc notices
during an allocation from libxml2 but the corruption was done earlier.
Use valgrind to track this down. Don't assume the problem is in other
people code,

Daniel


-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/



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