Boost logo

Boost Users :

Subject: [Boost-users] Segfault when trying to deserialize std::lists in a multi_array
From: Jiří Vyskočil (svzj_at_[hidden])
Date: 2011-07-24 19:44:29


Hello, I'm working on a parallel physical simulation involving particles
in a 3D grid.

In addition to Boost libraries, I use the Eigen3 template library for
holding numerical data in small 3-vectors.

I'm trying to send a 3D boost::multi_array containing std::list of
pointers to particle structs via boost::mpi and keep getting a segfault
on receive.

Sending and receiving boost::multi_array of V3D Eigen3 vectors works fine.

Serialization functions for multi_array are from
http://tinyurl.com/3koafmr (edited for 3 dimensions, seems to work)
Serializing Eigen Vector3d type (seems to work):

    friend class boost::serialization::access;
    template<class Archive>
    inline void serialize(Archive & ar, const unsigned int file_version) {
        ar & m_coeffs.x();
        ar & m_coeffs.y();
        ar & m_coeffs.z();
    }

typedef Vector3d V3D; //Convenience typedef for Eigen3 vector

struct Particle {
    V3D r, u;
    double m, q;
    unsigned number;

    friend class boost::serialization::access;
    template<class Archive>
    void serialize(Archive & ar, const unsigned int file_version) {
        ar & r; ar & u;
        ar & m; ar & q;
        ar & number;
    }
};

Sending point:

typedef boost::multi_array<std::list<Particle*>, 3> ParticleArray;

ParticleArray part_array(boost::extents[x][y][z]);
...fill the array with particles, some cells might be empty...
world->isend(recnum, pack_type, part_array);

Receiving point:

ParticleArray
part_array(boost::extents[slice->shape()[0]][slice->shape()[1]][slice->shape()[2]]);
world->recv(sendnum, pack_type, part_array);

When I get here, it segfaults:

terminate called after throwing an instance of
'boost::archive::archive_exception'
  what(): class version
# 0 0
Program received signal SIGABRT, Aborted.
0x00007ffff5a29a25 in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x00007ffff5a29a25 in raise () from /lib64/libc.so.6
#1 0x00007ffff5a2b0af in abort () from /lib64/libc.so.6
#2 0x00007ffff64fb695 in __gnu_cxx::__verbose_terminate_handler () at
/var/tmp/portage/sys-devel/gcc-4.4.5/work/gcc-4.4.5/libstdc++-v3/libsupc++/vterminate.cc:93
#3 0x00007ffff64f9ac6 in __cxxabiv1::__terminate (handler=0x70d) at
/var/tmp/portage/sys-devel/gcc-4.4.5/work/gcc-4.4.5/libstdc++-v3/libsupc++/eh_terminate.cc:38
#4 0x00007ffff64f9af3 in std::terminate () at
/var/tmp/portage/sys-devel/gcc-4.4.5/work/gcc-4.4.5/libstdc++-v3/libsupc++/eh_terminate.cc:48
#5 0x00007ffff64f9bee in __cxxabiv1::__cxa_throw (obj=<value optimized
out>, tinfo=<value optimized out>, dest=<value optimized out>) at
/var/tmp/portage/sys-devel/gcc-4.4.5/work/gcc-4.4.5/libstdc++-v3/libsupc++/eh_throw.cc:83
#6 0x000000000044f7d5 in
boost::archive::detail::iserializer<boost::mpi::packed_iarchive,
Particle>::load_object_data(boost::archive::detail::basic_iarchive&,
void*, unsigned int) const ()
#7 0x00007ffff794173b in load_object (this=0x7fffffffcae0, t=<value
optimized out>, bis=...) at libs/serialization/src/basic_iarchive.cpp:367
#8 boost::archive::detail::basic_iarchive::load_object
(this=0x7fffffffcae0, t=<value optimized out>, bis=...) at
libs/serialization/src/basic_iarchive.cpp:547
#9 0x000000000044f662 in
boost::archive::detail::pointer_iserializer<boost::mpi::packed_iarchive,
Particle>::load_object_ptr(boost::archive::detail::basic_iarchive&,
void*&, unsigned int) const ()
#10 0x00007ffff7941c50 in load_pointer (this=0x7fffffffcae0,
t=@0x7fffffffc880, bpis_ptr=0x668060, finder=<value optimized out>) at
libs/serialization/src/basic_iarchive.cpp:494
#11 boost::archive::detail::basic_iarchive::load_pointer
(this=0x7fffffffcae0, t=@0x7fffffffc880, bpis_ptr=0x668060,
finder=<value optimized out>) at
libs/serialization/src/basic_iarchive.cpp:560
#12 0x000000000044ed6f in
boost::archive::detail::iserializer<boost::mpi::packed_iarchive,
std::list<Particle*, std::allocator<Particle*> >
>::load_object_data(boost::archive::detail::basic_iarchive&, void*,
unsigned int) const ()
#13 0x00007ffff79416fa in load_object (this=0x7fffffffcae0, t=<value
optimized out>, bis=...) at libs/serialization/src/basic_iarchive.cpp:399
#14 boost::archive::detail::basic_iarchive::load_object
(this=0x7fffffffcae0, t=<value optimized out>, bis=...) at
libs/serialization/src/basic_iarchive.cpp:547
#15 0x000000000044ffb4 in
boost::archive::detail::iserializer<boost::mpi::packed_iarchive,
boost::multi_array<std::list<Particle*, std::allocator<Particle*> >,
3ul, std::allocator<std::list<Particle*, std::allocator<Particle*> > > >
>::load_object_data(boost::archive::detail::basic_iarchive&, void*,
unsigned int) const ()
#16 0x00007ffff79416fa in load_object (this=0x7fffffffcae0, t=<value
optimized out>, bis=...) at libs/serialization/src/basic_iarchive.cpp:399
#17 boost::archive::detail::basic_iarchive::load_object
(this=0x7fffffffcae0, t=<value optimized out>, bis=...) at
libs/serialization/src/basic_iarchive.cpp:547
#18 0x00000000004516f9 in boost::mpi::status
boost::mpi::communicator::recv_impl<boost::multi_array<std::list<Particle*,
std::allocator<Particle*> >, 3ul, std::allocator<std::list<Particle*,
std::allocator<Particle*> > > > >(int, int,
boost::multi_array<std::list<Particle*, std::allocator<Particle*> >,
3ul, std::allocator<std::list<Particle*, std::allocator<Particle*> > >
>&, mpl_::bool_<false>) const ()
#19 0x000000000044982d in recv<ParticleArray> (this=0x66b150,
slice=0x8779e0, pack_type=<value optimized out>, sendnum=1) at
/usr/include/boost/mpi/communicator.hpp:1201
#20 Communicator::receive (this=0x66b150, slice=0x8779e0,
pack_type=<value optimized out>, sendnum=1) at
/home/strazce/prog/opice/opice/src/communicator.cpp:62
#21 0x000000000043d512 in Experiment::run (this=0x66b0c0) at
/home/strazce/prog/opice/opice/src/experiment.cpp:96
#22 0x000000000042c13c in main (argc=1, argv=0x7fffffffd158) at
/home/strazce/prog/opice/opice/src/opice.cpp:29
(gdb)

Again, this error only shows when receiving the multi_array of
std::list<Particle*>. multi_array of V3D is received fine.

Thanks for any help,
Jiri Vyskocil


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net