Description
Some source code as
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SetDOMParser.h
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/dom/DOMNode.hpp>
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/util/XMLUni.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/framework/StdOutFormatTarget.hpp>
#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/sax/ErrorHandler.hpp>
SetDOMParser.cpp
...
setDOMParser::set::DOMParser()
{
...
parser = new XercesDOMParser;
...
}
SetDOMParser::internal_parse(filename)
{
...
parser->parse(filename);
...
}
...
setParse.cpp
int main(int argc, const char *argv[])
...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
filename is transfer by parameter argv[].
Built and run the program. Inputing command format like:
setParse [filename]
When input the filename whose length is longer than 130 chars, like
---------------------------------------
setParse a01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891
---------------------------------------
program will cast "Segmentation faul" error and break.
Why???? Who can help me?
I used gdb to debug. Followed is some backtrace info:
-----------------------------------------------------------------------------
#0 0x005e901e in free () from /lib/tls/libc.so.6
#1 0x004a7dd3 in __dynamic_cast () from /usr/lib/libstdc++.so.5
#2 0x009f655d in xercesc_2_5::MemoryManagerImpl::deallocate () from /usr/lib/libxerces-c.so.25
#3 0x009618a9 in xercesc_2_5::ArrayJanitor<unsigned short>::reset ()
from /usr/lib/libxerces-c.so.25
#4 0x00961871 in xercesc_2_5::ArrayJanitor<unsigned short>::~ArrayJanitor ()
from /usr/lib/libxerces-c.so.25
#5 0x00a83780 in xercesc_2_5::XMLScanner::scanDocument () from /usr/lib/libxerces-c.so.25
#6 0x0095819e in xercesc_2_5::AbstractDOMParser::parse () from /usr/lib/libxerces-c.so.25
#7 0x08050c37 in SetDOMParser::internal_parse (this=0x7fff8350, filename=0x9a86bb0 "a012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891") at SetDOMParser.cpp:125
#8 0x08051088 in SetDOMParser::parse (this=0x7fff8350, filename=0x9a86bb0 "a012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891") at SetDOMParser.cpp:250
#9 0x0804e84d in setParse() at setParse.cpp:186
#10 0x0804f0d1 in main (argc=3, argv=0x7fff8500) at setParse.cpp:330
-----------------------------------------------------------------------------
Why appears Segmentation fault when the length of parsing filename > 130 characters??
Thanks.
— MIDI