[xml] libxml2 and mingw32 issues



Hi,

I'm debugging my app with gdb-mingw32. I'm using libxml2 v2.6.30 that
I have re-built from sources with a modified configure script to prevent
libxml2 to use both win32threads and pthreads (thus breaking threading.)
The modified version works much better but there are still issues and the
app sometimes crashes after a few calls to this function:


int parse_xml_file(FILE *fp, const char* url, const Params *prm, int *rss_ttl)
{
        xmlDoc          *doc = NULL;
        xmlNode         *root_element = NULL;

        if ((doc = xmlParseFile(url)) == NULL)
                return RSS_UNPARSABLE;
        else {
                if ((root_element = xmlDocGetRootElement(doc)) == NULL) {
                        xmlFreeDoc(doc);
                        return RSS_EMPTY;
                }
                get_selected_elements(root_element, doc, fp, prm, rss_ttl);
                xmlFreeDoc(doc);
                return RSS_OK;
        }
}

void get_selected_elements(xmlNode *some_element, xmlDoc *doc, FILE *fp, const Params *prm, int *rss_ttl)
{
        xmlNode         *cur_node = NULL;
        xmlChar         *str;

        for (cur_node = some_element; cur_node != NULL; cur_node = cur_node->next) {
                if (prm->rss_title == 'y' &&
                                xmlStrcmp(cur_node->name, (const xmlChar *)"title") == 0) {
                        if ((str = xmlNodeListGetString(doc, cur_node->children, 1)) != NULL)
                                fprintf(fp, "%s%s\n", str, prm->rss_title_delimiter);
                        xmlFree(str);
                }
                else if (prm->rss_description == 'y' &&
                                xmlStrcmp(cur_node->name, (const xmlChar *)"description") == 0) {
                        if ((str = xmlNodeListGetString(doc, cur_node->children, 1)) != NULL)
                                fprintf(fp, "%s%s\n", str, prm->rss_description_delimiter);
                        xmlFree(str);
                }
                else if (xmlStrcmp(cur_node->name, (const xmlChar *)"ttl") == 0) {
                        if ((str = xmlNodeListGetString(doc, cur_node->children, 1)) != NULL)
                                *rss_ttl = atoi((char *)str);
                        else
                                *rss_ttl = prm->rss_refresh;
                        xmlFree(str);
                }
                get_selected_elements(cur_node->children, doc, fp, prm, rss_ttl);
        }
        return;
}

And here is the backtrace:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1920.0xd94]
0x7c918fea in ntdll!RtlpWaitForCriticalSection ()
  from C:\WINDOWS\system32\ntdll.dll
(gdb) backtrace
#0  0x7c918fea in ntdll!RtlpWaitForCriticalSection ()
  from C:\WINDOWS\system32\ntdll.dll
#1  0x7c90104b in ntdll!RtlEnumerateGenericTableLikeADirectory ()
  from C:\WINDOWS\system32\ntdll.dll
#2  0x0003b0a8 in ?? ()
#3  0x70faf0b1 in xmlGetGlobalState () at threads.c:658
#4  0x70fae68d in __xmlGenericError () at globals.c:857
#5  0x70f5da7a in xmlInitParser () at parser.c:12878
#6 0x70f5e343 in xmlSAXParseFileWithData (sax=0x0, filename=0xb6b670 "http://newsrss.bbc.co.uk/rss/newsonline_world_edition/technology/rss.xml";, recovery=0, data=0x0) at parser.c:12321 #7 0x70f5e4c5 in xmlSAXParseFile (sax=0x0, filename=0xb6b670 "http://newsrss.bbc.co.uk/rss/newsonline_world_edition/technology/rss.xml";, recovery=0) at parser.c:12385
#8  0x70f5e51f in xmlParseFile (
   filename=0xb6b670 "http://newsrss.bbc.co.uk/rss/newsonline_world_edition/technology/rss.xml";) at 
parser.c:12416
#9 0x00405932 in parse_xml_file (fp=0x77c5fce0, url=0xb6b670 "http://newsrss.bbc.co.uk/rss/newsonline_world_edition/technology/rss.xml";, prm=0xb6b890, rss_ttl=0x416048) at news_rss.c:100 #10 0x0040583a in get_rss_feed (resrc=0xb6b670, prm=0xb6b890, rss_ttl=0x416048) at news_rss.c:66
#11 0x00402a39 in load_resource (resrc=0xb6b670, rss_ttl=0x416048)
   at news_resource.c:44
#12 0x00401c3b in shift2left_callback (timer_id=16, dwUser=0)
   at news_main.c:427
#13 0x00401aea in timer_callback (timer_id=16, uMsg=0, dwUser=0, dw1=0, dw2=0)
   at news_main.c:393
#14 0x76b454f3 in WINMM!DrvGetModuleHandle ()
  from C:\WINDOWS\system32\winmm.dll
#15 0x76b5ae36 in timeSetEvent () from C:\WINDOWS\system32\winmm.dll
#16 0x76b5af3a in timeGetTime () from C:\WINDOWS\system32\winmm.dll
#17 0x7c80b50b in KERNEL32!GetModuleFileNameA ()
  from C:\WINDOWS\system32\kernel32.dll
#18 0x00000000 in ?? ()
(gdb)

My app works fine on linux, so what am I doing wrong?

Manu TM





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