473,320 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

core dump on xmlStrcmp


Hi

I tried the code below ( parseDoc ) on my xml file ( see below ) but this
gives me a core dump on xmlStrcmp function. It seems that cur->name is a
NULL pointer. cur->contents has the value 'story'.

What am I doing wrong ?

xml file

<?xml version="1.0"?>
<story>
<storyinfo>
<author>Some author</author>
</storyinfo>
</story>

void parseDoc( char *docname )
{
xmlDocPtr doc;
xmlNodePtr cur;

doc = xmlParseFile(docname);

if (doc == NULL ) {
fprintf(stderr,"Document not parsed successfully. \n");
return;
}

cur = xmlDocGetRootElement(doc);

if (cur == NULL) {
fprintf(stderr,"empty document\n");
xmlFreeDoc(doc);
return;
}

// Next function call gives core dump because cur->name is NULL pointer

if (xmlStrcmp(cur->name, (const xmlChar *) "story")) {
fprintf(stderr,"document of the wrong type, root node != story");
xmlFreeDoc(doc);
return;
}

}
Jul 20 '05 #1
2 3720
Johan den Boer wrote:
Hi

I tried the code below ( parseDoc ) on my xml file ( see below ) but this
gives me a core dump on xmlStrcmp function. It seems that cur->name is a
NULL pointer. cur->contents has the value 'story'.

What am I doing wrong ?

xml file

<?xml version="1.0"?>
<story>
<storyinfo>
<author>Some author</author>
</storyinfo>
</story>

void parseDoc( char *docname )
{
xmlDocPtr doc;
xmlNodePtr cur;

doc = xmlParseFile(docname);

if (doc == NULL ) {
fprintf(stderr,"Document not parsed successfully. \n");
return;
}

cur = xmlDocGetRootElement(doc);

if (cur == NULL) {
fprintf(stderr,"empty document\n");
xmlFreeDoc(doc);
return;
}

// Next function call gives core dump because cur->name is NULL pointer

if (xmlStrcmp(cur->name, (const xmlChar *) "story")) {
fprintf(stderr,"document of the wrong type, root node != story");
xmlFreeDoc(doc);
return;
}

}


I took your code and tried this on my machine (SunBlade 150, Solaris 9,
libxml2-2.4.23).
Everything works like expected: name = "story" !

Breakpoint 1, parseDoc (docname=0x10a10 "test.xml") at test.c:26
26 if (xmlStrcmp(cur->name, (const xmlChar *) "story")) {
(gdb) p *cur
$2 = {_private = 0x0, type = XML_ELEMENT_NODE, name = 0x20fa0 "story",
children = 0x34a88, last = 0x34c08, parent = 0x349f0,
next = 0x0, prev = 0x0, doc = 0x349f0, ns = 0x0, content = 0x0,
properties = 0x0, nsDef = 0x0}
(gdb)

What's the version of your libxml ?

Regards - Frank

Jul 20 '05 #2
Sorry i linked with libxml in stead of libxml2
"Johan den Boer" <me@knoware.nl> schreef in bericht
news:vn************@corp.supernews.com...

Hi

I tried the code below ( parseDoc ) on my xml file ( see below ) but this
gives me a core dump on xmlStrcmp function. It seems that cur->name is a
NULL pointer. cur->contents has the value 'story'.

What am I doing wrong ?

xml file

<?xml version="1.0"?>
<story>
<storyinfo>
<author>Some author</author>
</storyinfo>
</story>

void parseDoc( char *docname )
{
xmlDocPtr doc;
xmlNodePtr cur;

doc = xmlParseFile(docname);

if (doc == NULL ) {
fprintf(stderr,"Document not parsed successfully. \n");
return;
}

cur = xmlDocGetRootElement(doc);

if (cur == NULL) {
fprintf(stderr,"empty document\n");
xmlFreeDoc(doc);
return;
}

// Next function call gives core dump because cur->name is NULL pointer
if (xmlStrcmp(cur->name, (const xmlChar *) "story")) {
fprintf(stderr,"document of the wrong type, root node != story");
xmlFreeDoc(doc);
return;
}

}

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nick Craig-Wood | last post by:
I've just discovered that my python (Python 2.3.4 from debian package 2.3.4-1 running on debian testing x86 + linux 2.4.26) core dumps when I set recursionlimit very high and do lots of recursion....
1
by: Martin | last post by:
I use dbx and i got the following error: Reading GL_CliConnMgr core file header read successfully Reading ld.so.1 dbx: core file read error: address 0xff3e6000 not available dbx: core file...
10
by: ken | last post by:
hello, i'm writing a c program on a linux system. i'm debugging a segmentation fault but i don't want it to dump a core file because the memory footprint of the program is over 300Mb and i don't...
10
by: John Liu | last post by:
We upgraded from 7.2 to 7.4, it looks like everything working, but when I issue a query such as select * from tab (tab has about 2-3 million records), it causes core dump. I tuned some the...
3
by: John Liu | last post by:
AIX pg version 7.4 Select * from document2 core dump. Did a few more experiments with select * from document2 limit... I limit to 500000 it works, 600000 it exits but says "calloc:...
4
by: madhusudan.hv | last post by:
hi, Can you tell me when an application might take long time to dump core? The linux o.s is indicating that a process is dumping core, and only after 40 mins i am seeing the core file. What might...
10
by: wong_powah | last post by:
I want to find out where (which line) my C program core dump. How to do that? Is there a web site describing the procedure? One approach is to use stack trace of the mdb debugger, but I does not...
14
by: Sheldon | last post by:
Hi, I have a python script that uses a C extention. I keep getting a recurring problem that causes a core dump a few lines after the C extention return data back tp python. I tried using pbd and...
5
by: johnericaturnbull | last post by:
Hi - I am very new to python. I get this random core dump and am looking for a good way to catch the error. I know the function my core dump occurs. Is there any error catching/handling that I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.