Re: [xml] Segfault in xmlDocDumpMemory with efence



On Thu, Feb 19, 2004 at 03:23:31PM -0800, Dirk Morris wrote:
Daniel Veillard wrote:

Crash in malloc in Linux are usually due to a corrupted
memory allocator data structure. Use valgrind with your code it
offers a far more systematic check than efence,


I believe Electric fence's malloc doesnt use fenceposts like the libc's 
malloc, so I doubt this is the issue.
Each allocation gets its own page surrounded by two unmapped pages, so 
it is impossible to walk
to any other allocated memory without hitting an unmapped page first.

I can't use valgrind on this code because it doesnt support the needed 
system calls yet.

  you have libxml2 code, gdb and see what's happening in that 
xmlBufferCreate()

xmlBufferPtr
xmlBufferCreate(void) {
    xmlBufferPtr ret;
                                                                                
    ret = (xmlBufferPtr) xmlMalloc(sizeof(xmlBuffer));
    if (ret == NULL) {
        xmlTreeErrMemory("creating buffer");
        return(NULL);
    }
    ret->use = 0;
    ret->size = xmlDefaultBufferSize;
    ret->alloc = xmlBufferAllocScheme;
    ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
    if (ret->content == NULL) {
        xmlTreeErrMemory("creating buffer");
        xmlFree(ret);
        return(NULL);
    }
    ret->content[0] = 0;
    return(ret);
}

 xmlDefaultBufferSize is 4096 by default. If the memory structures
are not corrupted, tell me what's happening !

Daniel


-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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