0

タイトルにあるように、セグ フォールトが発生しましたが、原因がわかりません。私が掘り下げることができる最も近いおそらく関連する問題はこれです。私のシステム仕様は次のとおりです。

  • 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== 
4

1 に答える 1

0

長いコメント:

pthreads(OpenMP ランタイムで使用される)との静的リンクは、libpthreads.aアーカイブ全体がリンクされていない限り正しく機能しません。これを回避するに-Wl,--whole-archive -lpthreads -Wl,--no-whole-archiveは、コンパイル オプションに追加する必要があります。

しかし、あなたのコードには並列領域がないので、OpenMP を有効にするのは冗長です。さらに、内部から呼び出された何かでエラーが発生するため、RTTI が icpc で失敗しているように見えますextended_type_info_typeid.hpp

于 2012-09-13T06:58:56.963 に答える