# Crashing when exiting GLFW 3.0.3 on fullscreen mode

**URL:** <https://discourse.glfw.org/t/crashing-when-exiting-glfw-3-0-3-on-fullscreen-mode/614>\
**Category:** support\
**Created:** [October 14, 2013, 4:32am UTC](https://discourse.glfw.org/t/crashing-when-exiting-glfw-3-0-3-on-fullscreen-mode/614 "2013-10-14T04:32:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [October 14, 2013, 4:32am UTC](https://discourse.glfw.org/t/crashing-when-exiting-glfw-3-0-3-on-fullscreen-mode/614/1 "2013-10-14T04:32:39Z")

</div>

**[rebirth123](https://sourceforge.net/u/rebirth123/)** wrote on [Monday, October 14, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/31fe0904/#0b51):

GLFW 2 worked flawlessly but I decided to try out this new version and experience the changes. I can get it to work in a windowed mode without any problems, but as soon as I try fullscreen mode I am getting serious lock ups which is forcing me to hard reset my PC.

I have tried to setup fullscreen with a lower resolution than the native resolution on my primary monitor, but this results in a total black screen lockup. If I set the resolution to the native (current) resolution of my primary monitor then opengl renders correctly, but as soon as I press escape to exit, I get a total black screen lockup which forces me to hard reset my PC. Alt-Ctrl-Del is not working, so this makes it difficult (and tedious) to find a fix.

Windows 7 sp1  
GTX 780  
Multi-monitor configuration  
VS2010

Here is the initialization code:

bool initialize(int wWidth, int wHeight, bool fullScreen, std::string title)  
{  
glfwSetErrorCallback(\_errorCallback);

```
if(!glfwInit())
{
	return false;
}

glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
glfwWindowHint(GLFW_STENCIL_BITS, 8);
glfwWindowHint(GLFW_DEPTH_BITS, 24);
glfwWindowHint(GLFW_SAMPLES, 0);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

    if(fullScreen)
        _window = glfwCreateWindow(wWidth, wHeight, title.c_str(), glfwGetPrimaryMonitor(), NULL);
    else
        _window = glfwCreateWindow(wWidth, wHeight, title.c_str(), NULL, NULL);

    if(!_window)
    {
        glfwTerminate();
    return false;
    }

    glfwSetWindowSizeCallback(_window, _windowResizeCallback);
glfwGetFramebufferSize(_window, &_windowWidth, &_windowHeight);
glfwSetKeyCallback(_window, _keyCallback);
glfwMakeContextCurrent(_window);

glewExperimental = true;
GLenum err = glewInit();
if(GLEW_OK != err) 
{
	shutdown();
	return false;
}

    printf("GL Version: %s\n", glGetString(GL_VERSION));
    return true;

```

}

void shutdown()  
{  
//glfwDestroyWindow(\_window); //tried to comment this out but made no difference  
glfwTerminate();  
}

Hope you can help.

P.S. I took out all of the GL error checks in my paste (to save space for the relevant code) GL is reporting no errors.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [October 14, 2013, 11:28am UTC](https://discourse.glfw.org/t/crashing-when-exiting-glfw-3-0-3-on-fullscreen-mode/614/2 "2013-10-14T11:28:41Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Monday, October 14, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/31fe0904/#c8a8):

Are you calling `shutdown` from a callback?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [October 14, 2013, 6:41pm UTC](https://discourse.glfw.org/t/crashing-when-exiting-glfw-3-0-3-on-fullscreen-mode/614/3 "2013-10-14T18:41:06Z")

</div>

**[rebirth123](https://sourceforge.net/u/rebirth123/)** wrote on [Monday, October 14, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/31fe0904/#c8a8/ebda):

No, I’m not. At the moment the \_keyCallback function is just like the example:

void \_keyCallback(GLFWwindow\* window, int key, int scancode, int action, int mods)  
{  
if(key == GLFW\_KEY\_ESCAPE && action == GLFW\_PRESS)  
glfwSetWindowShouldClose(window, GL\_TRUE);  
}

The rendering while loop is controlled with the glfwWindowShouldClose(\_window) function.

The shutdown() function is called just before the program ends in int main() and is the last function called, after I have destroyed all objects/shaders etc.

It works fine in windowed mode and a similar setup using GLFW2 in fullscreen mode. All monitors go black when it locks up, which I imagine is a graphics driver crash (latest official Nvidia drivers).

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [October 15, 2013, 2:25am UTC](https://discourse.glfw.org/t/crashing-when-exiting-glfw-3-0-3-on-fullscreen-mode/614/4 "2013-10-15T02:25:09Z")

</div>

**[rebirth123](https://sourceforge.net/u/rebirth123/)** wrote on [Tuesday, October 15, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/31fe0904/#78db):

I believe I have a problem with my PC. I have written a very basic program using glfw3 to run on my old Aspire 5738g laptop and it’s working OK.

I don’t believe the problem is related to the Nvidia driver (I tried others), but it may either be a problem in the OS or a fault with the GFX card (it’s fairly new). However, the latter seems unlikely as it functions fine in all games and tests.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [October 15, 2013, 3:30am UTC](https://discourse.glfw.org/t/crashing-when-exiting-glfw-3-0-3-on-fullscreen-mode/614/5 "2013-10-15T03:30:28Z")

</div>

**[rebirth123](https://sourceforge.net/u/rebirth123/)** wrote on [Tuesday, October 15, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/31fe0904/#55d1):

Actually, this gets even stranger, and happens in both VS2010 and VS2012.

If I close down the IDE and run the built executables, the program behaves perfectly with no black screen crashes on exit.

I am now convinced GLFW3 works flawlessly as GLFW2 does (I tested other win32 methods too), but am at a total loss as to what is going on.

Does anyone know why this might be happening when running the program from these IDEs in fullscreen mode (F5 - debug mode)? I don’t ever recall this happening before.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [October 16, 2013, 9:07pm UTC](https://discourse.glfw.org/t/crashing-when-exiting-glfw-3-0-3-on-fullscreen-mode/614/6 "2013-10-16T21:07:05Z")

</div>

**[rebirth123](https://sourceforge.net/u/rebirth123/)** wrote on [Wednesday, October 16, 2013](https://sourceforge.net/p/glfw/discussion/247562/thread/31fe0904/#68ac):

After a reinstall of OS and software everything is working fine again. Sadly, the problem coincided with the time I started to test out GLFW, so I created this thread to see if there was something obviously wrong with the initialization code.

The problems in this thread are not related to GLFW3, which is actually very good with some well-thought out features.

Sorry for wasting your time.
