[Therion] loch segmentation fault at launch

Olly Betts olly at survex.com
Tue Jan 14 02:38:34 CET 2025


[Including the list in my reply as this seems of broader interest]

On Mon, Jan 13, 2025 at 04:52:46PM -0600, Bill Gee wrote:
> Olly, you're a wizard for remembering that bit of arcana.  The command line
> you suggested works.  No more seg faults in loch!

Great.

> I do not have any packages called "wxWidgets" installed.  On Fedora they are
> called wxGTK.  Here is the list of packages I have:
> 
> bgee at main2:~$ rpm -qa | grep -i wxGTK
> wxGTK-i18n-3.2.6-1.fc41.noarch
> wxGTK-3.2.6-1.fc41.x86_64
> wxGTK-gl-3.2.6-1.fc41.x86_64
> wxGTK-webview-3.2.6-1.fc41.x86_64
> wxGTK-media-3.2.6-1.fc41.x86_64
> wxGTK-devel-3.2.6-1.fc41.x86_64

Its upstream project name is wxWidgets - wxGTK is the flavour using GTK,
which Fedora have chosen to use as their package name.

> I also do not have any packages like "libglew".  It might be part of the VTK
> package.  I see a file named vtk-glew.h.

It's not part of VTK - that header seems to be some VTK layer for
supporting building with different versions of glew.

I don't think wxWidgets or therion uses glew so you may well not have it
installed, but some other apps which use wxWidgets also use glew - I
think it's necessary that wxWidgets and glew agree on whether to use EGL
or not for those apps.

> I will modify the launcher for loch to set the environment variable.

We have a workaround in Survex's aven for this - I'd suggest something
similar in loch would be helpful as it would avoid these crashes
completely.  I'm not easily able to test this patch actually works as I
don't have Fedora but this or something like it should do the job (I
have checked it compiles on a platform where the conditionals both
evaluate true):

diff --git a/loch/lxGUI.cxx b/loch/lxGUI.cxx
index fc00b31e..41a4583c 100644
--- a/loch/lxGUI.cxx
+++ b/loch/lxGUI.cxx
@@ -73,7 +73,29 @@
 #endif
 
 
+#ifdef __WXGTK3__
+# if !(wxUSE_GLCANVAS_EGL-0)
+#  include <stdlib.h>
+
+// The GLX-based wxGLCanvas doesn't work under Wayland, and the code
+// segfaults: https://github.com/wxWidgets/wxWidgets/issues/17702
+//
+// Therefore we force X11 unless we're using the EGL-based wxGLCanvas
+// (which was added in wxWidgets 3.1.5 and hasn't been backported to
+// 3.0.x).
+//
+// Setting GDK_BACKEND=x11 is the recommended workaround, and it seems to
+// work to set it here.  GTK2 doesn't support Wayland, so doesn't need
+// this.
+struct ForceX11 {
+    ForceX11() {
+       setenv("GDK_BACKEND", "x11", 1);
+    }
+};
+static ForceX11 forcex11;
 
+# endif
+#endif
 
 ////////////////////////////////////////////////////////////////////////
 // Main frame


Cheers,
    Olly


More information about the Therion mailing list