如标题所述,我发生了段错误,我不知道为什么。我可以挖掘的最接近的可能相关问题是this。我的系统规格如下:
- RHELv5u8
- icpc 12.1.0 版(gcc 4.1.2 版兼容性)
- 拱 = x86_64
使用g++编译时似乎没有出现问题。
我已将问题隔离为一小段代码:
#include <iostream>
#include <cstdio>
#include <vector>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/vector.hpp>
#include <string>
#include <fstream>
using namespace std;
int main()
{
cout << "Testing ... ";
vector<int> outVect(10);
// Save the data
std::ofstream outputFile_("archive.txt");
outputFile_ << std::scientific;
boost::archive::text_oarchive textOutArchive_(outputFile_);
cout << "chk1" << endl;
textOutArchive_ & BOOST_SERIALIZATION_NVP(outVect);
cout << "chk2" << endl;
return 0;
}
我正在编译:
icpc -g -static -openmp standalone.cc -o minimal -lboost_serialization ; ./minimal
有任何想法吗?
Valgrind 给了我以下信息:
Testing ... chk1
==24519== Jump to the invalid address stated on the next line
==24519== at 0x0: ???
==24519== by 0x403100: boost::serialization::detail::extended_type_info_typeid_1<std::vector<int, std::allocator<int> > const>::get_instance() (extended_type_info_typeid.hpp:96)
==24519== by 0x4027C0: boost::archive::detail::oserializer<boost::archive::text_oarchive, std::vector<int, std::allocator<int> > >::oserializer() (oserializer.hpp:106)
==24519== by 0x402934: boost::archive::detail::oserializer<boost::archive::text_oarchive, std::vector<int, std::allocator<int> > >::instantiate() (oserializer.hpp:135)
==24519== by 0x402764: boost::archive::detail::save_non_pointer_type<boost::archive::text_oarchive, std::vector<int, std::allocator<int> > >::save_standard::invoke(boost::archive::text_oarchive&, std::vector<int, std::allocator<int> > const&) (oserializer.hpp:264)
==24519== by 0x4027AA: boost::archive::detail::save_non_pointer_type<boost::archive::text_oarchive, std::vector<int, std::allocator<int> > >::save_conditional::invoke(boost::archive::text_oarchive&, std::vector<int, std::allocator<int> > const&) (oserializer.hpp:273)
==24519== by 0x40274A: boost::archive::detail::save_non_pointer_type<boost::archive::text_oarchive, std::vector<int, std::allocator<int> > >::invoke(boost::archive::text_oarchive&, std::vector<int, std::allocator<int> > const&) (oserializer.hpp:322)
==24519== by 0x40364E: void boost::archive::save<boost::archive::text_oarchive, std::vector<int, std::allocator<int> > >(boost::archive::text_oarchive&, std::vector<int, std::allocator<int> > const&) (oserializer.hpp:536)
==24519== by 0x401A85: void boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::save_override<std::vector<int, std::allocator<int> > const>(std::vector<int, std::allocator<int> > const&, int) (basic_text_oarchive.hpp:78)
==24519== by 0x4021D5: boost::archive::text_oarchive& boost::archive::detail::interface_oarchive<boost::archive::text_oarchive>::operator<< <std::vector<int, std::allocator<int> > const>(std::vector<int, std::allocator<int> > const&) (interface_oarchive.hpp:78)
==24519== by 0x402E49: void boost::serialization::nvp<std::vector<int, std::allocator<int> > >::save<boost::archive::text_oarchive>(boost::archive::text_oarchive&, unsigned int) const (nvp.hpp:77)
==24519== by 0x402C9E: void boost::serialization::access::member_save<boost::archive::text_oarchive, boost::serialization::nvp<std::vector<int, std::allocator<int> > > const>(boost::archive::text_oarchive&, boost::serialization::nvp<std::vector<int, std::allocator<int> > > const&, unsigned int) (access.hpp:93)
==24519== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==24519==
==24519==
==24519== Process terminating with default action of signal 11 (SIGSEGV)
==24519== Bad permissions for mapped region at address 0x0
==24519== at 0x0: ???
==24519== by 0x403100: boost::serialization::detail::extended_type_info_typeid_1<std::vector<int, std::allocator<int> > const>::get_instance() (extended_type_info_typeid.hpp:96)
==24519== by 0x4027C0: boost::archive::detail::oserializer<boost::archive::text_oarchive, std::vector<int, std::allocator<int> > >::oserializer() (oserializer.hpp:106)
==24519== by 0x402934: boost::archive::detail::oserializer<boost::archive::text_oarchive, std::vector<int, std::allocator<int> > >::instantiate() (oserializer.hpp:135)
==24519== by 0x402764: boost::archive::detail::save_non_pointer_type<boost::archive::text_oarchive, std::vector<int, std::allocator<int> > >::save_standard::invoke(boost::archive::text_oarchive&, std::vector<int, std::allocator<int> > const&) (oserializer.hpp:264)
==24519== by 0x4027AA: boost::archive::detail::save_non_pointer_type<boost::archive::text_oarchive, std::vector<int, std::allocator<int> > >::save_conditional::invoke(boost::archive::text_oarchive&, std::vector<int, std::allocator<int> > const&) (oserializer.hpp:273)
==24519== by 0x40274A: boost::archive::detail::save_non_pointer_type<boost::archive::text_oarchive, std::vector<int, std::allocator<int> > >::invoke(boost::archive::text_oarchive&, std::vector<int, std::allocator<int> > const&) (oserializer.hpp:322)
==24519== by 0x40364E: void boost::archive::save<boost::archive::text_oarchive, std::vector<int, std::allocator<int> > >(boost::archive::text_oarchive&, std::vector<int, std::allocator<int> > const&) (oserializer.hpp:536)
==24519== by 0x401A85: void boost::archive::basic_text_oarchive<boost::archive::text_oarchive>::save_override<std::vector<int, std::allocator<int> > const>(std::vector<int, std::allocator<int> > const&, int) (basic_text_oarchive.hpp:78)
==24519== by 0x4021D5: boost::archive::text_oarchive& boost::archive::detail::interface_oarchive<boost::archive::text_oarchive>::operator<< <std::vector<int, std::allocator<int> > const>(std::vector<int, std::allocator<int> > const&) (interface_oarchive.hpp:78)
==24519== by 0x402E49: void boost::serialization::nvp<std::vector<int, std::allocator<int> > >::save<boost::archive::text_oarchive>(boost::archive::text_oarchive&, unsigned int) const (nvp.hpp:77)
==24519== by 0x402C9E: void boost::serialization::access::member_save<boost::archive::text_oarchive, boost::serialization::nvp<std::vector<int, std::allocator<int> > > const>(boost::archive::text_oarchive&, boost::serialization::nvp<std::vector<int, std::allocator<int> > > const&, unsigned int) (access.hpp:93)
==24519==