Recently moved to windows10 -> my glfw window randomly crashes


I do some C++ programming on my leisure time. I have been working on a flight sim project for nearly two years with glfw and glad on windows 7. I recently had a problem with my PC and I had to move from windows 7 to windows 10. I reinstalled code::blocks and recompile my project.

My program starts and runs for a few seconds or minutes, then the glfw window randomly crashes and my program terminates without any error code or text. It never happened before with windows 7.

I downloaded glfw-3.3.6 binaries for win64 and also updated glad. It didn’t help.

Any advice ? where to start ?

Here is my initialisation code, if it may help :

void MyGLFWerror(int code, const char* text)
cout << "Erreur GLFW " << code << ", " << text << endl;

int main()
// initialisation du generateur aleatoire


// glfw window creation
// --------------------

GLFWwindow* window;
GLFWmonitor *monitor=glfwGetPrimaryMonitor();

    glfwWindowHint(GLFW_RED_BITS, 8);
    glfwWindowHint(GLFW_GREEN_BITS, 8);
    glfwWindowHint(GLFW_BLUE_BITS, 8);
    glfwWindowHint(GLFW_REFRESH_RATE, 60);
    window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "Simu_V11", monitor, NULL);
    window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "Simu_V11", NULL, NULL);

if (window == NULL)
    std::cout << "Failed to create GLFW window" << std::endl;
    return -1;
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glfwSetScrollCallback(window, scroll_callback);
glfwSetCursorPos(window,static_cast<float>(SCR_WIDTH)/2.0f, static_cast<float>(SCR_HEIGHT)/2.0f);

// glad: load all OpenGL function pointers
// ---------------------------------------
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
    std::cout << "Failed to initialize GLAD" << std::endl;
    return -1;


Start by running program under debugger - and when it crashes, check the place where it crashed in debugger. Examine callstack to see how did code get there and examine variable values to understand why.


Thank you for your input mmozeiko. It took me a few hours but I managed to find the problem with the debugger and a couple of cout << variable .

It turned out that the issue had nothing to do with glfw initialisation of procedures. It was a data structure badly initialised. But it had been working for months with windows 7…