This is my code. And I am getting error double free or corruption (fasttop) c++
//iterations
for (int iter=0;iter<iterations;iter++) {
printf("Iteration %d\n",iter);
printf("\tStreaming Edges\n");
//for each edge which the source has a label but the destination has not.
//Assign the label to the matrix
graph.stream_edges<VertexId>(
[&](Edge & e){
if ((vertices_labels[e.source]>=0) && (vertices_labels[e.target]<0)){
aux_labels[e.target].push_back(vertices_labels[e.source]);
}
return 0;
}, nullptr, 0, 1
);
printf("\tStreaming Nodes\n");
//get the most predominant vertice in the matrix
graph.stream_vertices<VertexId>(
[&](VertexId i){
if (vertices_labels[i]<0){
int maxCount = -1;
int result = -1;
for (int j=0;j<aux_labels[i].size();j++){
int value = aux_labels[i].at(j);
int c = 1;
for (int k=j+1;k<aux_labels[i].size();k++){
if (aux_labels[i].at(k)==value){
c++;
if (c>maxCount){
maxCount = c;
result = aux_labels[i].at(k);
}
}
}
}
write_add(&vertices_labels[i], result+1);
}
return 0;
}
);
}
can someone tell me where might be the problem? P.s. i am using Big vector. When I try to run it in Linux inside my virtual box of macbook, it runs fine. But when I try to run it Linux machine, it gives me error (double free or corruption (fasttop)). I believe that it occurs on real machine because of concurrency maybe. Any suggestion or insight is welcomed!