# Recently moved to windows10 -\> my glfw window randomly crashes

**URL:** <https://discourse.glfw.org/t/recently-moved-to-windows10-my-glfw-window-randomly-crashes/2026>\
**Category:** support\
**Created:** [March 20, 2022, 5:54pm UTC](https://discourse.glfw.org/t/recently-moved-to-windows10-my-glfw-window-randomly-crashes/2026 "2022-03-20T17:54:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![YannOO](https://avatars.discourse-cdn.com/v4/letter/y/67e7ee/32.png) [@YannOO](https://discourse.glfw.org/u/YannOO)\
**Post date:** [March 20, 2022, 5:54pm UTC](https://discourse.glfw.org/t/recently-moved-to-windows10-my-glfw-window-randomly-crashes/2026/1 "2022-03-20T17:54:17Z")

</div>

Hi,

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  
srand(time(nullptr));

```
glfwSetErrorCallback(MyGLFWerror);
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

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

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

#if FULL_SCREEN
    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);
#else
    window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "Simu_V11", NULL, NULL);
#endif

if (window == NULL)
{
    std::cout << "Failed to create GLFW window" << std::endl;
    glfwTerminate();
    return -1;
}
glfwMakeContextCurrent(window);
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;
}

```

…"

---

<div class="post-metadata">

**Author:** ![mmozeiko](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/mmozeiko/32/29_2.png) [@mmozeiko](https://discourse.glfw.org/u/mmozeiko)\
**Post date:** [March 20, 2022, 8:43pm UTC](https://discourse.glfw.org/t/recently-moved-to-windows10-my-glfw-window-randomly-crashes/2026/2 "2022-03-20T20:43:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![YannOO](https://avatars.discourse-cdn.com/v4/letter/y/67e7ee/32.png) [@YannOO](https://discourse.glfw.org/u/YannOO)\
**Post date:** [March 23, 2022, 7:27pm UTC](https://discourse.glfw.org/t/recently-moved-to-windows10-my-glfw-window-randomly-crashes/2026/3 "2022-03-23T19:27:09Z")

</div>

Hi.

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…
