Segmentation fault

I have this recursive function that segfaults in a bizarre way.

void Main::surroundCheck(int x, int y) {
  if (x < 0 || y < 0 || x >= 16 || y >= 16) {
    return;
  }

  go_board[x][y]->setState(4);

  Main::surroundCheck(x + 1,y);
  Main::surroundCheck(x - 1,y);
  Main::surroundCheck(x,y + 1);
  Main::surroundCheck(x,y - 1);

}

go_board is a two dimensional array of objects that are subclasses of Sprite and they have a state which i am now trying to alter. With the following code i could just use a for loop to change all tiles to state 4 but i need to use this method because i will later add functionality that requires the use of this kind of function. I call this function with the following line from a function called onTouchBegan() which is called by a touch event listener:
this->surroundCheck(3,3);

I am very puzzled by this because i have used a similar function before in my other project and it worked fine.

It seems you have infinite recursion and stack overflow at end.

What idea of that function? To set state 4 for all items in 2d array?

Thank you for pointing this out, i am now just trying to implement a flood fill anlgorithm in a really simple way. I will later use it to detect surrounded areas in a Go game (the board game). The solution was that i created an other array that tells if a tile was visited.

You are calling the same function from within itself. This results in recursion as also noted by @dimon4eg

I would call it from update() if you need it to happen immediately.