Hello,
Following code gets segfault occasionally with same
input in a multithreaed env(gnu/linux rh as/glibc 2.96/g++...):
formater::formater(const char
*bufin)
{ char *tmp = NULL; if(bufin == NULL) return;
tmp = new char[strlen(bufin)+1];
strcpy(tmp, bufin);
xmlKeepBlanksDefault(0);
//the line below is formater.cpp 30 which causes
the problem -- malloc
m_doc = xmlParseMemory(tmp,
strlen(tmp));
... ////////////////////////////////////////////////////////
// stack trace here
///////////////////////////////////////////////////////
#0 chunk_alloc (ar_ptr=0x402b82c0, nb=56) at
malloc.c:3001
#1 0x40203828 in __libc_malloc (bytes=52) at malloc.c:2811 #2 0x40074bbe in xmlNewTextLen () from /usr/lib/libxml2.so.2 #3 0x40074c5f in xmlNewDocTextLen () from /usr/lib/libxml2.so.2 #4 0x40073a89 in xmlStringGetNodeList () from /usr/lib/libxml2.so.2 #5 0x400555a7 in my_attribute () from /usr/lib/libxml2.so.2 #6 0x40055809 in attribute () from /usr/lib/libxml2.so.2 #7 0x40055e68 in startElement () from /usr/lib/libxml2.so.2 #8 0x4006bd95 in xmlParseStartTag () from /usr/lib/libxml2.so.2 #9 0x4006c856 in xmlParseElement () from /usr/lib/libxml2.so.2 #10 0x4006e22b in xmlParseDocument () from /usr/lib/libxml2.so.2 #11 0x40071cc5 in xmlSAXParseMemoryWithData () from /usr/lib/libxml2.s #12 0x40071d49 in xmlSAXParseMemory () from /usr/lib/libxml2.so.2 #13 0x40071d73 in xmlParseMemory () from /usr/lib/libxml2.so.2 #14 0x0806778f in formater::formater (this=0x8868e20, __in_chrg= bufin=0x49000010 "<wddxPacket version='1.0'><header> <comment>PHP<.. at formater.cpp:30 ...
What's the possible reason for this?
TIA
Xiang
|