Problem with vector and cilk_spawn

Florent Hivert Florent.Hivert@lri.fr
Thu Mar 9 22:36:00 GMT 2017


      Dear all,

It seems that there is a problem with dynamic allocation and cilk_spawn. The
following code fails randomly with GCC-6 and GCC-7 (it fails with ICE on
GCC-5). It works without any problems on one core machine. Some times it works
perfectly, some times it segfault. I also had some double free failure.

I don't know have any idea on how to get it down to a shorter code or to debug
it. Any suggestion ? Should I just report the bug ?

Best,

Florent Hivert


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

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

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



More information about the Gcc-help mailing list