SIGSEGV (Address boundary error)

int main(void) {
  float *x, *y;
  cudaMallocManaged(&x, sizeof(float));
  cudaMallocManaged(&y, sizeof(float));
  x[0] = 1.0f;
  y[0] = 1.0f;
  cudaFree(x);
  cudaFree(y);
  return 0;
}
nvcc main.cu -o main
./main
fish: “./main” terminated by signal SIGSEGV (Address boundary error)

& when I use bash (instead of fish), I get:

Segmentation fault (core dumped)

Weirdly, this error goes away when I remove the y variable completely…

int main(void) {
  float *x;
  cudaMallocManaged(&x, sizeof(float));
  x[0] = 1.0f;
  cudaFree(x);
  return 0;
}

I suggest using proper CUDA error checking.

As a quick test you can also do:

cuda-memcheck ./main

I’m sorry, weirdly after I rebooted my PC the problem has gone away… I should I tried doing this before posting this on the forums. You may close the topic.