-
Notifications
You must be signed in to change notification settings - Fork 127
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 when repeatedly opening/closing GUI #335
base: develop
Are you sure you want to change the base?
Conversation
Cairo keeps a global cache list of connections, but since the reference count of the device never reaches 0, the devices are never removed from this cache list. The crash happens when a new xcb_connection is made, and the new pointer happens to be the same as an existing pointer in this cache list, then the wrong cairo_xcb_connection is returned. Then no screen can be found, since the root is not the same for that old xcb_connection and the new one. Thus we end up at ASSERT_NOT_REACHED in _get_screen_index(), in cairo-xcb-screen.c Note that there is some resource leakage somewhere, since the reference count of the cairo devices should reach 0 at some point, but never do. Fixes steinbergmedia#334
Thanks for looking into that @madah81pnz1 I just reproduced the crash. I load a single instance of AGain.vst3 on a track in reaper and rapidly press the 'FX' button to quickly open/close the editor. The stacktrace looks like the one in your issue #334 Unfortunately your fix does not work here as the CairoGraphicsDeviceFactory::Impl destructor is not being hit under the debugger when only opening/closing the editor. CairoGraphicsDeviceFactory::Impl only gets destroyed when you unload the plug-in entirely. What am I missing here? Are you doing something more than I am?
Yes, that is correct. The reference count is not null here either. |
My plugin is not using vst3editor.cpp though, it's based on https://github.com/surge-synthesizer/clap-saw-demo/blob/main/src/linux-vstgui-adapter.cpp In my case, I could only reproduce the crash when VSTGUI::exit/init was called several times, since that left some dangling pointers in cairo. If I don't call VSTGUI::exit, the crash never happens for me in reaper. For me the crash always happens when the next editor is created. It is then clear my fix doesn't work. In the linked issue ryukau/VSTPlugins#54 it also crashes sometimes even with my fix.
Do you mean this is by design, or this is one of the bugs? |
This commit (66ba211#diff-2867d84eec098746cb067c5c069d48234e851d42c749599f36fbf80bf986c194L175) by @scheffle removed one important line accidentally I assume:
(This is a fix for #249) @madah81pnz1 Please try to add this line back. This immediately fixes the crash here. |
No, this was not an accident. What's most likely missing now is a
|
…close editor crash)
Cairo keeps a global cache list of connections, but since the reference count of the device never reaches 0, the devices are never removed from this cache list.
The crash happens when a new xcb_connection is made, and the new pointer happens to be the same as an existing pointer in this cache list, then the wrong cairo_xcb_connection is returned. Then no screen can be found, since the root is not the same for that old xcb_connection and the new one. Thus we end up at ASSERT_NOT_REACHED in _get_screen_index(), in cairo-xcb-screen.c
Note that there is some resource leakage somewhere, since the reference count of the cairo devices should reach 0 at some point, but never do.
Fixes #334