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

Opening two instances of the VST UI causes Carla to crash #1

Open
pdesaulniers opened this issue May 14, 2021 · 7 comments
Open

Opening two instances of the VST UI causes Carla to crash #1

pdesaulniers opened this issue May 14, 2021 · 7 comments

Comments

@pdesaulniers
Copy link

pdesaulniers commented May 14, 2021

To reproduce:

  • Load two instances of the VST in Carla
  • Open both UIs

As soon as we open the second UI, Carla crashes:

==10627== Process terminating with default action of signal 6 (SIGABRT): dumping core
==10627==    at 0x4C5CEF5: raise (in /usr/lib/libc-2.33.so)
==10627==    by 0x4C46861: abort (in /usr/lib/libc-2.33.so)
==10627==    by 0x4C46746: __assert_fail_base.cold (in /usr/lib/libc-2.33.so)
==10627==    by 0x4C55645: __assert_fail (in /usr/lib/libc-2.33.so)
==10627==    by 0x25CC0C98: ImGui::ErrorCheckNewFrameSanityChecks() (imgui.cpp:7143)
==10627==    by 0x25CB3B08: ImGui::NewFrame() (imgui.cpp:3910)
==10627==    by 0x25CA7FD1: DISTRHO::ImGuiUI::onDisplay() (ImGuiUI.cpp:88)
==10627==    by 0x25D6AC53: DGL::Widget::PrivateData::display(unsigned int, unsigned int, double, bool) (WidgetPrivateData.cpp:88)
==10627==    by 0x25D67A03: DGL::Window::PrivateData::onPuglDisplay() (Window.cpp:926)
==10627==    by 0x25D689D8: DGL::Window::PrivateData::onDisplayCallback(PuglViewImpl*) (Window.cpp:1295)
==10627==    by 0x25D646D1: puglDisplay (pugl_x11.c:397)
==10627==    by 0x25D6538A: puglProcessEvents (pugl_x11.c:681)

Perhaps this is due to ImGui's reliance on static variables?

@pdesaulniers pdesaulniers changed the title Opening two instances of the VST UI cause Carla to crash Opening two instances of the VST UI causes Carla to crash May 14, 2021
@jpcima
Copy link
Owner

jpcima commented May 14, 2021

Perhaps this is due to ImGui's reliance on static variables?

Just checked it, it's because GL2/3 backend files don't support multiple contexts.

void ImGui::ErrorCheckNewFrameSanityChecks(): l'assertion « g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8()?" » a échoué.

I found a related PR which stores context-specific data.
If I understand right, this is only a matter of implementing the same mechanism in these other backends.
ocornut/imgui#3934

@jpcima
Copy link
Owner

jpcima commented May 15, 2021

I've just made this patch, it should enable OpenGL2 to work
imgui-opengl2.diff.txt
imgui-opengl2.diff.txt

@pdesaulniers
Copy link
Author

I can still reproduce the issue with the patch. However, Valgrind now reports an uninitialised value when I open the UI:

==18322== Use of uninitialised value of size 8
==18322==    at 0x263B0B5E: ImHashData(void const*, unsigned long, unsigned int) (imgui.cpp:1498)
==18322==    by 0x2642C0DF: ImGui_ImplOpenGL2_GetID() (imgui_impl_opengl2.cpp:68)
==18322==    by 0x2642C0EE: ImGui_ImplOpenGL2_New() (imgui_impl_opengl2.cpp:73)
==18322==    by 0x2642C1CB: ImGui_ImplOpenGL2_Init() (imgui_impl_opengl2.cpp:102)
==18322==    by 0x263AD89D: DISTRHO::ImGuiUI::Impl::setupGL() (ImGuiUI.cpp:276)
==18322==    by 0x263AD63D: DISTRHO::ImGuiUI::Impl::Impl(DISTRHO::ImGuiUI*) (ImGuiUI.cpp:230)
==18322==    by 0x263ACEBA: DISTRHO::ImGuiUI::ImGuiUI(int, int) (ImGuiUI.cpp:59)
==18322==    by 0x263AC913: DISTRHO::UISimpleGain::UISimpleGain() (UISimpleGain.cpp:37)
==18322==    by 0x263ACCC7: DISTRHO::createUI() (UISimpleGain.cpp:125)
==18322==    by 0x26449199: DISTRHO::createUiWrapper(void*, DGL::Window*) (DistrhoUIInternal.hpp:173)
==18322==    by 0x26449226: DISTRHO::UIExporterWindow::UIExporterWindow(DGL::Application&, long, double, void*) (DistrhoUIInternal.hpp:184)
==18322==    by 0x26449618: DISTRHO::UIExporter::UIExporter(void*, long, void (*)(void*, unsigned int, bool), void (*)(void*, unsigned int, float), void (*)(void*, char const*, char const*), void (*)(void*, unsigned char, unsigned char, unsigned char), void (*)(void*, unsigned int, unsigned int), float, void*, char const*) (DistrhoUIInternal.hpp:272)

@jpcima
Copy link
Owner

jpcima commented May 15, 2021

Oops you're right, thanks for catching this one

return ImHashData(context, sizeof(void*));
change to
return ImHashData(&context, sizeof(void*));

@pdesaulniers
Copy link
Author

pdesaulniers commented May 15, 2021

Thanks, it works! 🎉

@pdesaulniers
Copy link
Author

pdesaulniers commented May 15, 2021

Oops, now I get an error when I click on the arrow in the header (at the left of the "Simple gain" label):

simplegain: ../../imgui/imgui.cpp:7185: void ImGui::ErrorCheckEndFrameSanityChecks(): Assertion `(g.CurrentWindowStack.Size == 1) && "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?"' failed.
==19807== 
==19807== Process terminating with default action of signal 6 (SIGABRT): dumping core
==19807==    at 0x4F10EF5: raise (in /usr/lib/libc-2.33.so)
==19807==    by 0x4EFA861: abort (in /usr/lib/libc-2.33.so)
==19807==    by 0x4EFA746: __assert_fail_base.cold (in /usr/lib/libc-2.33.so)
==19807==    by 0x4F09645: __assert_fail (in /usr/lib/libc-2.33.so)
==19807==    by 0x12966C: ImGui::ErrorCheckEndFrameSanityChecks() (imgui.cpp:7185)
==19807==    by 0x11DCA4: ImGui::EndFrame() (imgui.cpp:4385)
==19807==    by 0x11E0DC: ImGui::Render() (imgui.cpp:4461)
==19807==    by 0x1106BD: DISTRHO::ImGuiUI::onDisplay() (ImGuiUI.cpp:90)
==19807==    by 0x1D1FDB: DGL::Widget::PrivateData::display(unsigned int, unsigned int, double, bool) (WidgetPrivateData.cpp:88)
==19807==    by 0x1CED8B: DGL::Window::PrivateData::onPuglDisplay() (Window.cpp:926)
==19807==    by 0x1CFD60: DGL::Window::PrivateData::onDisplayCallback(PuglViewImpl*) (Window.cpp:1295)
==19807==    by 0x1CBA47: puglDisplay (pugl_x11.c:397)
Aborted (core dumped)

I can reproduce the issue when running a single instance of the plugin.

EDIT: my bad, this crash is unrelated to the issue at hand. I didn't notice it earlier because I was running a release build with assertions disabled

@jpcima
Copy link
Owner

jpcima commented May 15, 2021

Fixed also in the latest commit, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants