-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Fix crash in glfw backend when backend data is null #6222
Conversation
I don’t understand your explanation. Why would the backend data suddenly become null with callbacks installed ? Why not removing callbacks if you deinit the backend ? |
I have spent more time debugging this issue and hopefully it will make more sense: The render loop code goes like this :
It worked well until a proprietary plugin created a window in the middle of My first reflex was to fix this issue by testing the pointer for being null, specially because
I think it wouldn't be crazy to assume that I am not 100% sure this is the best solution, so as an alternative, I have a fix working installing and restoring glfw callbacks at every frame as you suggested. Best, C |
But why ? |
The second context is used to draw gizmos in an opengl offscreen render buffer which is then added as an image in the main ui. So io.BackendPlatformUserData is null because there is no need of backend in that particular case. Best, C |
You said:
It worked well until a proprietary plugin created a window in the middle of render3dFrameBuffer.
It called glfw callbacks with ImGui::GetIO().BackendPlatformUserData == nullptr
If the context is not meant to be used with a backend it should be bounds when backend callbacks are setup.
|
Thanks, |
My stance is that those those asserts/crashes are valuable and desirable ways to spot misusage, and that switching to "silent erroring" patterns is rarely desirable. While adding a NULL check would be convenient for our use case, it may make it more difficult for other users to spot other genuine mistakes. I would generally accept the null checks if it was proved it was the only situation to a tricky problem. I'll close this for now. Thanks for the details. |
That sounds good, thanks again for the quick help. |
Hi,
This crash happens when my application loads a proprietary plugin, which hijacks the window context to display it's own UI.
When the plugin is running, the imgui callbacks are still called with a null backend data which makes the code using it crash. When the proprietary plugin closes its UI, the backend data is available again.
Checking if the backend data pointer is null and returning early fixes this issue.
Let me know if that sounds like a reasonable fix.
Cheers,
Cyril