Okay, so finally I found a bug in the sudoku solver code. The problem is, given an unsolvable grid, this solution will go over infinite loop. And this is crazy right? I mean it should come out by saying that this grid is unsolvable. And I was expecting that my solve routing will return -1 in case of unsolvable sudoku, but it doesn’t. I need to fix it somehow.