Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault on glfwTerminate #2380

Open
recallmenot opened this issue Aug 19, 2023 · 0 comments
Open

Segfault on glfwTerminate #2380

recallmenot opened this issue Aug 19, 2023 · 0 comments
Labels
ANGLE bug Bug reports and bugfix pull requests EGL EGL API specific help needed Issues needing more contributors to solve X11

Comments

@recallmenot
Copy link

I have found a bug in GLFW when using ANGLE.
When calling glfwTerminate() (with a valid and working context), a segfault occurs.
I’ve run a gdb backtrace on it:

#0  0x00007ffff72fef37 in _XSend () from /usr/lib/libX11.so.6
#1  0x00007ffff72f77d9 in XQueryExtension () from /usr/lib/libX11.so.6
#2  0x00007ffff6de7dd8 in ?? () from /usr/lib/libGLX.so.0
#3  0x00007ffff6dea2f9 in ?? () from /usr/lib/libGLX.so.0
#4  0x00007ffff6dea799 in glXDestroyPbuffer () from /usr/lib/libGLX.so.0
#5  0x00007ffff79672b7 in rx::DisplayGLX::terminate() ()
   from /home/a/libraries/angle/out/Release/libGLESv2.so
#6  0x00007ffff77bbd90 in egl::Display::terminate(egl::Thread*, egl::Display::TerminateReason) ()
   from /home/a/libraries/angle/out/Release/libGLESv2.so
#7  0x00007ffff760fb92 in egl::Terminate(egl::Thread*, egl::Display*) ()
   from /home/a/libraries/angle/out/Release/libGLESv2.so
#8  0x00007ffff7611678 in EGL_Terminate () from /home/a/libraries/angle/out/Release/libGLESv2.so
#9  0x00007ffff7c73ec2 in eglTerminate () from /home/a/libraries/angle/out/Release/libEGL.so
#10 0x000055555559cc93 in _glfwTerminateEGL ()
#11 0x000055555558e53a in _glfwTerminateX11 ()
#12 0x000055555557be24 in terminate ()
#13 0x000055555557cea8 in glfwTerminate ()
#14 0x000055555557a083 in shutdown () at esshader.c:503
#15 0x000055555557a785 in main (argc=1, argv=0x7fffffffe2b8) at esshader.c:72

ANGLE was compiled from source, so was glfw.
Calling glfwDestroyWindow(window) does not improve this behavior.

I’m using GLFW to load Angle:

#define GLFW_INCLUDE_ES3
#include <GLFW/glfw3.h>

And to initialize I’m doing this:

	if (!glfwInit()) {
		die("Unable to initialize GLFW.\n");
	}

	glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
	glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);

	if (!(window = glfwCreateWindow(width, height, "esshader", monitor, NULL))) {
		glfwTerminate();
		die("Unable to create GLFW window.\n");
	}

	glfwMakeContextCurrent(window);

@mmozeiko over on the glfw discourse forum found the solution:
The fix for NVIDIA EGL having the same issue was to move _glfwTerminateEGL() but this breaks ANGLE.

_glfwTerminateEGL();

Moving it back to where it was before (below if (_glfw.x11.im) { ... }, nowadays L1589) eliminates the error; GLFW can then shut down fine with ANGLE.
Not trying to break NVIDIA EGL again either, a fix would need to be run-time, either detecting NVIDIA or ANGLE but I have no idea how to accomplish that.

If anyone has an idea, I could then finish up the PR.

@elmindreda elmindreda added bug Bug reports and bugfix pull requests X11 EGL EGL API specific labels Nov 21, 2023
@elmindreda elmindreda changed the title GLFW + Angle: segfault on glfwTerminate() Segfault on glfwTerminate Dec 14, 2023
@elmindreda elmindreda added the help needed Issues needing more contributors to solve label Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ANGLE bug Bug reports and bugfix pull requests EGL EGL API specific help needed Issues needing more contributors to solve X11
Projects
None yet
Development

No branches or pull requests

2 participants