Robert Kirnum - 2012-01-24

I have code running fine on Windows but segfaults on Linux!?  The segfault is in tinyxml.h at line 1688.  This is the ToElement method of the TiXmlHandle class.  The backtrace (g++ using -O0) is . . .
<<
(gdb) bt
#0  0x00000000 in ?? ()
#1  0xf0fd9845 in TiXmlHandle::ToElement (this=0xca41e2d8) at tinyxml.h:1688
#2  0xf0fc8048 in OverlayProcessor::ParseXML (this=0xcc40ed70,
    a_pStr=0x9deaba0 "<overlay id=\"asianText\" leftPosition=\"80%\" topPosition=\"5%\" horizontalSize=\"15%\" verticalSize=\"50%\" priority=\"0.3\" backgroundColor=\"black\" borderColor=\"yellow\" borderWidth=\"1.0\" duration=\"LifeOfConten"…) at OverlayProcessor.cpp:101
#3  0xf0fc9534 in OverlayProcessorParseXML (pOverlayProcessor=0xcc40ed70,
    a_pStr=0x9deaba0 "<overlay id=\"asianText\" leftPosition=\"80%\" topPosition=\"5%\" horizontalSize=\"15%\" verticalSize=\"50%\" priority=\"0.3\" backgroundColor=\"black\" borderColor=\"yellow\" borderWidth=\"1.0\" duration=\"LifeOfConten"…) at OverlayProcessor.cpp:35
#4  0xf0fb3040 in cnfrsc_Handle_CNFRSC_ParseOverlayXMLFile2 (ptr=0xe30d91b0) at cnfrsc_smfn.c:3088
#5  ParseOverlayXMLFileThread (ptr=0xe30d91b0) at cnfrsc_smfn.c:3009
#6  0x00b13832 in start_thread () from /lib/libpthread.so.0
#7  0x00a850ae in clone () from /lib/libc.so.6
>>

The code snippet . . .
<<
   TiXmlDocument l_tTiXmlDocument;
   TiXmlElement* l_pOverlayElement;
   l_tTiXmlDocument.Parse(a_pStr);
   TiXmlHandle l_tDocumentHandle(&l_tTiXmlDocument);
   //<overlay>
l_pOverlayElement = l_tDocumentHandle.FirstChild( "overlay" ).ToElement();
>>

This works fine on WIndows using the same XML string.  I tried playing with the optimization going from -O2 down to -O0.  This had no effect.  Could there be some other setting which needs to be tweaked on Linux?

Thanks,
Bob