boost c ++库的read_xml函数中的分段错误

时间:2019-01-07 11:04:19

标签: c++ c++11 boost

const char* File = "ABC.xml";
ifstream input(File);

using boost::property_tree::ptree;
ptree pt;
read_xml(input, pt);

我正在使用boost c ++库解析xml文件(ABC.xml)。

  • BOOST_LIB_VERSION“ 1_60”
  • Linux = fedora 24

代码编译成功,但是在read_xml(input,pt)处出现了分段错误。gdb中bt的输出为:

#0  0x00000000006621ce in __gnu_cxx::new_allocator<char>::construct<char, char>(char*, char&&) (this=0x7fffffff7e50,
__p=0x2000 <error: Cannot access memory at address 0x2000>,
__args#0=<unknown type in /home/code/CPApp, CU 0xbd61e, DIE 0xe933d>)
at /usr/include/c++/6.3.1/ext/new_allocator.h:120


#1  0x000000000065ebb3 in std::allocator_traits<std::allocator<char> >::construct<char, char>(std::allocator<char>&, char*, char&&) (
__a=..., __p=0x2000 <error: Cannot access memory at address 0x2000>,
__args#0=<unknown type in /home/code/CPApp, CU 0xbd61e, DIE 0xe933d>)
at /usr/include/c++/6.3.1/bits/alloc_traits.h:455

#2  0x000000000065ec38 in std::vector<char, std::allocator<char> >::_M_emplace_back_aux<char>(char&&) (this=0x7fffffff7e50,
__args#0=<unknown type in /home/code/CPApp, CU 0xbd61e, DIE 0xe933d>)
at /usr/include/c++/6.3.1/bits/vector.tcc:416

#3  0x000000000065b445 in std::vector<char, std::allocator<char> >::emplace_back<char>(char&&) (this=0x7fffffff7e50,
__args#0=<unknown type in /home/code/CPApp, CU 0xbd61e, DIE 0xe933d>)
at /usr/include/c++/6.3.1/bits/vector.tcc:101

#4  0x000000000065ea0b in std::vector<char, std::allocator<char> >::_M_range_initialize<std::istreambuf_iterator<char, std::char_traits<char> > > (this=0x7fffffff7e50, __first=..., __last=...) at /usr/include/c++/6.3.1/bits/stl_vector.h:1272

#5  0x000000000065afd7 in std::vector<char, std::allocator<char> >::_M_initialize_dispatch<std::istreambuf_iterator<char, std::char_traits<char> > > (this=0x7fffffff7e50, __first=..., __last=...) at /usr/include/c++/6.3.1/bits/stl_vector.h:1261

#6  0x0000000000657974 in std::vector<char, std::allocator<char> >::vector<std::istreambuf_iterator<char, std::char_traits<char> >, void>
(this=0x7fffffff7e50, __first=..., __last=..., __a=...) at /usr/include/c++/6.3.1/bits/stl_vector.h:406

#8  0x00000000006541be in boost::property_tree::xml_parser::read_xml<boost::property_tree::basic_ptree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > (stream=..., pt=..., flags=0)
at /usr/include/boost/property_tree/xml_parser.hpp:52

0 个答案:

没有答案