c++linuxopenglnvidiaglx

Process crashes when unsetting glXMakeContextCurrent


I didn't encounter this bug a couple of years ago (last time I ran headless OpenGL context on Ubuntu).

I create headeless GL context according to this example. I have zero issues with creation and running the app using this context. However,when I perform cleanup before shutdown, the moment this line

 glXMakeContextCurrent(xdisplay, 0, 0, 0);

is triggered,the whole app crashes. I don't get any stack trace,no segfault, or useful debugger info. The handle to xdisplay is valid as well as the context, and I verify it with the call to set current context before unsetting it:

 glXMakeContextCurrent(xdisplay, pbuff, pbuff, rc);

My system is : Ubuntu 16.04 64bit. GPU: GTX970 ,drivers:384.98 ,GLX:1.4

Would be happy to get a pointer to possible solution or at least possible cause to such a crash.

PS: Using "None" instead of zero or NULL changes nothing (if someone wonders)


Solution

  • I will answer this question, because the reason for the error was really weird. I mistakenly was setting SwapInterval on this context. But the context is headless, so it doesn't make sense to set SwapInterval. And it is really bad that the API doesn't know to return an error when calling SwapInterval on this type of context. Therefore,the issue disappeared once I removed SwapInterval call from my headless context.