When I debug my PRJ I get this error:
args Error: Multiple errors reported.\ Failed to execute MI command: -var-create -
args Error message from debugger back end: Attempt to dereference a generic pointer.\ Unable to create variable object
the error comes when casting from void* args to Mapper* arg.
UPDATE 1
KMaster, KMapper implements respectively Master, Mapper but they do not add nothing rilevant. Effectively is KMapper that call the method work()
. Here is the code:
int main(){
int np=1,K=4;
string path="lucca.gps";
KMaster* master=new KMaster(path,np,K);
KMapper* mapper[np];
master->splitting();
for(int i=0;i<np;i++){
mapper[i]=new KMapper(master,master->mData[i].key,master->mData[i].value);
while(mapper[i]->work()!=0){
cout<<"failed creating mapper, retry..."<<endl;
sleep(1000);
}
}
}
int KMaster::splitting(){
cout<<"start splitting"<<endl;
fstream is(path.c_str());
string s="";
getline(is,s);
while(!is.eof()){
for(int i=0;i<nProc;i++){
pair<double,double> res;
is>>res.first;
is>>res.second;
is>>s;
mapData[i].push_back(res);
Data.push_back(res);
if(is.eof()) break;
}
}
list<pair<double,double> >::iterator it=Data.begin();
int increment=Data.size()/K;
for(int i=0;i<K;i++){
Klusters.push_back(*it);
advance(it,increment);
}
for(int i=0;i<nProc;i++){
mData[i].key=&Klusters;
mData[i].value=&mapData[i];
}
cout<<"splitting completed"<<endl;
return 0;
}
int Mapper::work(){
Mapper* m=this;
void* p=m;
return pthread_create(&thread,NULL,start,p);
}
void* start(void* args){
cout<<"start()"<<endl;
Mapper* arg= reinterpret_cast<Mapper*>(args);
arg->mapResult=arg->map(arg->k,arg->v);
cout<<"Mapper finish, sending result..."<<endl;
arg->send(arg->mapResult);
}
Hope that someone can help!
UPDATE 2
Screenshot of the debugger: