StevensDeptECE / GrailGUI

GrailGUI is a prototype of a replacement for web programming (HTTP, HTML, CSS, JavaScript) and GUI programming. It includes a client graphical API, a browser implemented in C++ and OpenGL, a protocol to transmit metadata and data in binary, a language (XDL) to describe the binary data, and local storage to retain data on the client should that be necessary. Encrypted communications (equivalent of TLS) have not yet been implemented.
GNU General Public License v3.0
7 stars 14 forks source link

Fix Grail Segfaulting on quit #42

Closed dkrautha closed 3 years ago

dkrautha commented 3 years ago

I started walking through where things are dying when we try to quit, here's what I've found so far:

Solution: Initialize cam to nullptr in the constructor of Canvas, and then check whether it is a nullptr before we try and delete it.

I'm not sure what to do to solve this, simply commenting out the glDeleteProgram() call does work, but it probably causes us to leak memory.

dkrautha commented 3 years ago

Solution for Failure 2: We were calling GLWin's cleanup() function twice, once at the end of the mainloop, and another in the destructor of GLWin. This led to calling glDeleteProgram() again on something a program that had already been deleted giving a segfault.

There are two options to fix this, either remove the mainloop call or the destructor call. The correct choice was to remove the destructor call as after calling cleanup in the mainloop, glfwTerminate is called which likely destroys the opengl context, and caused an immediate segfault in the destructor (you can't call an opengl function without an opengl context).