Boost logo

Boost Users :

Subject: [Boost-users] scatter error
From: alev mutlu (koor230_at_[hidden])
Date: 2010-03-16 07:27:03


Hi
The code below compiles fine , but gives the

[ceng1:23288] *** Process received signal ***
[ceng1:23288] Signal: Segmentation fault (11)
[ceng1:23288] Signal code: Address not mapped (1)
[ceng1:23288] Failing at address: 0xfffffffffffffff9
[ceng1:23288] [ 0] /lib64/libpthread.so.0 [0x3baf40de80]
[ceng1:23288] [ 1]
/usr/lib64/libstdc++.so.6(_ZN9__gnu_cxx18__exchange_and_addEPVii+0x2)
[0x38d9cb7672]
[ceng1:23288] [ 2] /usr/lib64/libstdc++.so.6(_ZNSs6assignERKSs+0x9b)
[0x38d9c9ca4b]
[ceng1:23288] [ 3] test-boost(_ZN5fieldaSERKS_+0x47) [0x4219a1]
[ceng1:23288] [ 4]
test-boost(_ZNSt6__copyILb0ESt26random_access_iterator_tagE4copyIPK5fieldPS3_EET0_T_S8_S7_+0x3c)
[0x4221e0]
[ceng1:23288] [ 5]
test-boost(_ZSt10__copy_auxIPK5fieldPS0_ET0_T_S5_S4_+0x29) [0x422225]
[ceng1:23288] [ 6]
test-boost(_ZNSt13__copy_normalILb0ELb0EE6copy_nIPK5fieldPS2_EET0_T_S7_S6_+0x25)
[0x42224d]
[ceng1:23288] [ 7] test-boost(_ZSt4copyIPK5fieldPS0_ET0_T_S5_S4_+0x2d)
[0x42227d]
[ceng1:23288] [ 8]
test-boost(_ZN5boost3mpi6detail12scatter_implI5fieldEEvRKNS0_12communicatorEPKT_PS7_iiN4mpl_5bool_ILb0EEE+0x90)
[0x42a652]
[ceng1:23288] [ 9]
test-boost(_ZN5boost3mpi7scatterI5fieldEEvRKNS0_12communicatorEPKT_PS6_ii+0x50)
[0x42b184]
[ceng1:23288] [10]
test-boost(_ZN5boost3mpi7scatterI5fieldEEvRKNS0_12communicatorERKSt6vectorIT_SaIS7_EEPS7_ii+0x55)
[0x42b1fd]
[ceng1:23288] [11] test-boost(main+0x231) [0x4208a3]
[ceng1:23288] [12] /lib64/libc.so.6(__libc_start_main+0xf4) [0x3bae81d8b4]
[ceng1:23288] [13] test-boost(__gxx_personality_v0+0x169) [0x420489]
[ceng1:23288] *** End of error message ***
mpirun noticed that job rank 0 with PID 23288 on node ceng1-ib exited on
signal 11 (Segmentation fault).

run time errors. Is this due to miss-use of boost functions or am I doing
wrong with memory allocation?

#include <boost/mpi/environment.hpp>
#include <boost/mpi/communicator.hpp>
#include <boost/mpi/collectives.hpp>
#include <boost/thread/barrier.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/config.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/access.hpp>
#include <boost/serialization/string.hpp>
#include <string>
#include <iostream>
#include <vector>
#include <fstream>

#define MASTER 0

int arraySize = 7;

using namespace std;
namespace mpi = boost::mpi;

struct field {
    string field_name;
    string field_type;
    string field_ref;
    string field_colType;

};

namespace boost {
    namespace serialization{
        template<class Archive>
        void serialize(Archive & ar, struct field & f, unsigned int
version){
            ar & f.field_name;
            ar & f.field_type;
            ar & f.field_ref;
            ar & f.field_colType;
        }
    }
}

int main(int argc, char* argv[])
{
    mpi::environment env(argc, argv);
    mpi::communicator world;
    int m_mySize, w_mySize, kk,i;
    struct field *relAllValues;
    struct field *relMyValues;
    vector<struct field> C;
    struct field c;

    w_mySize = arraySize / world.size();
    cout << "w_mySize = " << w_mySize << endl;
    if (world.rank() == MASTER){
        for(int i = 0; i < arraySize; i++){
            c.field_name = "field_name=" + i;
            c.field_type = "field_type=" + i;
            c.field_ref = "field_ref=" + i;
            c.field_colType = "field_colType=" + i;
            C.push_back(c);
        }
          m_mySize = arraySize / world.size() + arraySize % world.size();
          relMyValues = (struct field *) malloc(sizeof(struct field) *
m_mySize);
          relAllValues = (struct field *) malloc(sizeof(struct field) *
arraySize);
    }
      else{
         relMyValues = (struct field *) malloc(sizeof(struct field) *
w_mySize);
      }

      if (world.rank() == MASTER){
          scatter(world, C, relMyValues, w_mySize, 0);
      }
      else{
          scatter(world, C, relMyValues, w_mySize, 0);
      }
}



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