Как указано в заголовке, у меня произошла ошибка сегмента, и я понятия не имею, почему. Самая близкая, возможно связанная проблема, которую я мог выкопать, является этот. Мои системные характеристики следующие:
И проблема, кажется, не возникает при компиляции с 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
Есть идеи?
Вальгринд дает мне следующее:
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==
Длинный комментарий:
Статическая связь с pthreads
(используется во время выполнения OpenMP) никогда не работает правильно, если только libpthreads.a
архив связан с. Чтобы обойти это, вы должны добавить -Wl,--whole-archive -lpthreads -Wl,--no-whole-archive
к вариантам компиляции.
Но тогда я не вижу параллельных областей в вашем коде, поэтому активация OpenMP избыточна. Кроме того, похоже, что RTTI не работает с icpc, так как ошибка возникает в чем-то, вызванном изнутри extended_type_info_typeid.hpp
,
Других решений пока нет …