iLCSoft / Marlin

Modular Analysis and Reconstruction for the LINear Collider
GNU General Public License v3.0
11 stars 16 forks source link

fix "invalid read" errors from valgrind, prevent crash in XML parsing #34

Closed andresailer closed 5 years ago

andresailer commented 5 years ago

BEGINRELEASENOTES

ENDRELEASENOTES

crash

The crash can (maybe?) be reproduced with attached steering file (renamed to xml) break.txt

source /cvmfs/clicdp.cern.ch/iLCSoft/builds/2019-02-20/x86_64-slc6-gcc62-opt/init_ilcsoft.sh
wget https://github.com/iLCSoft/Marlin/files/3013507/break.txt -O break.xml
Marlin break.xml

invalid read

Example valgrind output

==21315== Invalid read of size 8
==21315==    at 0x4ECA406: TiXmlNode::NextSibling(char const*) const (tinyxml.cc:386)
==21315==    by 0x4C8525B: IterateChildren (tinyxml.h:570)
==21315==    by 0x4C8525B: marlin::XMLParser::parse() (XMLParser.cc:160)
==21315==    by 0x40E5AE: main (Marlin.cc:277)
==21315==  Address 0x145894c0 is 96 bytes inside a block of size 216 free'd
==21315==    at 0x4A09186: operator delete(void*) (vg_replace_malloc.c:575)
==21315==    by 0x4ECA2F3: TiXmlNode::RemoveChild(TiXmlNode*) (tinyxml.cc:327)
==21315==    by 0x4C85417: marlin::XMLParser::parse() (XMLParser.cc:179)
==21315==    by 0x40E5AE: main (Marlin.cc:277)
==21315==  Block was alloc'd at
==21315==    at 0x4A080BC: operator new(unsigned long) (vg_replace_malloc.c:333)
==21315==    by 0x4ECF3A9: TiXmlNode::Identify(char const*, TiXmlEncoding) (tinyxmlparser.cc:892)
==21315==    by 0x4ED0C45: TiXmlElement::ReadValue(char const*, TiXmlParsingData*, TiXmlEncoding) (tinyxmlparser.cc:1229)
==21315==    by 0x4ED0FDE: TiXmlElement::Parse(char const*, TiXmlParsingData*, TiXmlEncoding) (tinyxmlparser.cc:1124)
==21315==    by 0x4ECF50C: TiXmlDocument::Parse(char const*, TiXmlParsingData*, TiXmlEncoding) (tinyxmlparser.cc:767)
==21315==    by 0x4ECAE0D: TiXmlDocument::LoadFile(_IO_FILE*, TiXmlEncoding) (tinyxml.cc:1077)
==21315==    by 0x4ECB0A6: TiXmlDocument::LoadFile(char const*, TiXmlEncoding) (tinyxml.cc:953)
==21315==    by 0x4C84002: LoadFile (tinyxml.h:1409)
==21315==    by 0x4C84002: marlin::XMLParser::parse() (XMLParser.cc:28)
==21315==    by 0x40E5AE: main (Marlin.cc:277)