# glfwTerminate() problem

**URL:** <https://discourse.glfw.org/t/glfwterminate-problem/210>\
**Category:** support\
**Created:** [October 5, 2012, 10:32pm UTC](https://discourse.glfw.org/t/glfwterminate-problem/210 "2012-10-05T22:32:05Z")\
**Posts on this page:** 3\
**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 5, 2012, 10:32pm UTC](https://discourse.glfw.org/t/glfwterminate-problem/210/1 "2012-10-05T22:32:05Z")

</div>

**[liamstask](https://sourceforge.net/u/liamstask/)** wrote on [Friday, October 05, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/040f89bd/#4035):

Hello! I’m maintaining an application developed with glfw 2.7.2 and am trying  
to upgrade to 2.7.6.

On OS X, I see that glfw\_atexit() is called on a thread that is not the  
main thread, and segfaults during glfwTerminate() - there’s a comment in  
cocoa\_init.m \_glfwPlatformTerminate() that says “fail unless this is the  
main thread”…if I insert a check for the main thread there and return  
GL\_FALSE, all goes according to plan.

Alternatively, if I call glfwTerminate() myself on the main thread and  
disable glfw\_atexit(), everything works.

Is this a known issue, or does this possibly indicate some other step I need  
to take in upgrading from 2.7.2 to 2.7.6? Obviously there are a couple  
workarounds, but each require editing glfw source, which I’d prefer to avoid  
if possible 🙂

Thanks.

---

<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 5, 2012, 10:46pm UTC](https://discourse.glfw.org/t/glfwterminate-problem/210/2 "2012-10-05T22:46:45Z")

</div>

**[liamstask](https://sourceforge.net/u/liamstask/)** wrote on [Friday, October 05, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/040f89bd/#27a5):

Ah, nevermind. I see this was already manually edited out of the glfw sources  
in the previous version of my app as well.

In any event, it would be nice to be able to optionally disable the  
installation of the atexit handler.

Thanks 🙂

---

<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 7, 2012, 12:23am UTC](https://discourse.glfw.org/t/glfwterminate-problem/210/3 "2012-10-07T00:23:14Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Sunday, October 07, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/040f89bd/#3c84):

That’s a bug in GLFW 2.7.6. Thank you for finding it!

The other ports already have this check. I’ve added the check to the OS X port  
as well. The fix will be included in GLFW 2.7.7, or you can get it right away  
from Subversion (although your local fix is likely just as good).
