Re: [xml] xmlFree() segmentation fault with dinamic library

On Wed, May 11, 2005 at 06:59:31PM +0200, SOM3ONE wrote:
here is the code examle i was using to test the problem:

  Step 1/ clean up the shared lib crap and fall back to clean C

paphio:~/XML -> cat tst.c
#include <stdio.h>
#include "libxml/xmlmemory.h"
#include "libxml/parser.h"

main(int argc, char **argv)

    xmlDocPtr doc;
    xmlNodePtr cur;
    xmlChar *attr;

    doc = xmlParseFile("test.xml");
    if (doc == 0) {
        printf("xmlParseFile error\n");
        return 1;

    cur = xmlDocGetRootElement(doc);
    if (cur == 0) {
        printf("xmlDocGetRootElement error\n");
        return 1;

    if (xmlStrcmp(cur->name, (const xmlChar *) "OSDaB_XML")) {
        printf("invalid root\n");
        return 1;

    attr = xmlGetProp(cur, (const xmlChar *) "version");
    if (attr != 0) {
        printf("version: %s\n", attr);

    return 0;

paphio:~/XML ->

  Step 2/ compile in a clean way against the installed shared librairies

paphio:~/XML -> gcc -Wall  -o tst `xml2-config --cflags` tst.c `xml2-config --libs`
paphio:~/XML ->

  Step 3/ check the shared libraries

paphio:~/XML -> ldd tst => /usr/lib/ (0x007b7000) => /usr/lib/ (0x009bc000) => /lib/tls/ (0x0018b000) => /lib/tls/ (0x00b03000) => /lib/ (0x0044f000)
        /lib/ (0x00717000)
paphio:~/XML ->

  Step 4/ verify it works

paphio:~/XML -> ./tst
version: 1.0
paphio:~/XML ->

I really can't realize where the problem could be!
the xml test file is parsed correctly by other xml parsers (like the one
used by Trolltech's Qt toolkit).

   libxml2 parses it correctly too of course, no problem. Now something
is screwed in the way you use the C++ or the dynamic shared library loading
but this has positively nothing to do with libxml2 as I just demonstrated.


Daniel Veillard      | Red Hat Desktop team
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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