I have a program to use Opanmpi, for the for-loop parallel within the I loop, shared thread Will write the variable, so I have to synchronize them. However, I can sometimes get a segment error or a double free or corruption error. Does anyone know what happens? Thanks and good luck! Here's the code: void KNNClassifier :: classify_various_k (int dim, double * feature, integer label, int * ks, double * errors, integer nb_ks, integer k_max) {ANNpoint queryPt = 0; ANNidxArray nnIdx = 0; Anisteare distances = 0; QueryPt = Feature; NnIdx = new [k_max]; Disks = new k_max]; If (SRCMP (_search_neighbors, "cruel") == 0) {// search_search_struct-> gt; Anchor search (queryPt, k_max, nnIdx, diskette, _p); } Else if (strcmp (_search_neighbors, "kdtree") == 0) {_search_struct-> AnnkSearch (queryPt, k_max, nnIdx, dists, _eps); // double free or corruption} (int j = 0; j & lt; nb_ks; j ++) {scalar_t result = 0.0; For (int i = 0; i gt; nb_examples) {nb_try = i; ...