jeudi 9 mars 2017

Cilkplus random behavior with std::vectors

The following (reduced) code is very badly handled by the series of GCC

#include <vector>
#include <cilk/cilk.h>

void walk(std::vector<int> v, int bnd, unsigned size) {
  if (v.size() < size)
    for (int i=0; i<bnd; i++) {
      std::vector<int> vnew(v);
      vnew.push_back(i);
      cilk_spawn walk(vnew, bnd, size);
    }
}

int main(int argc, char **argv) {
  std::vector<int> v{};
  walk(v , 5, 5);
}

Specifically:

  • G++ 5.3.1 crash:

     red.cpp: In function ‘<built-in>’:
     red.cpp:20:39: internal compiler error: in lower_stmt, at gimple-low.c:397
            cilk_spawn walk(vnew, bnd, size);
    
    
  • G++ 6.3.1 create a code which works perfectly well if executed on one core but segfault sometime, signal a double free some other times if using more cores. A student who has a arch linux g++7 reported a similar result.

My question : is there something wrong with that code. Am I invoking some undefined behavior or is it simply a bug I should report ?

Aucun commentaire:

Enregistrer un commentaire