View Issue Details

IDProjectCategoryView StatusLast Update
0003913FreeCADBugpublic2019-07-29 15:01
ReporterAvenger Assigned Towmayer  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
PlatformLinuxOSArch LinuxOS Version2019/03/20
Product Version0.18 
Fixed in Version0.18 
Summary0003913: libspnav crash on linux wayland during startup
DescriptionWhen starting the 0.18dev version of FreeCAD on Arch Linux running KDE under wayland it crashes during startup before the main window is shown (after the splash).

The FreeCAD version used is 0.18-90-g4a41c27cd.
libspnav: 0.2.3-2

Building with Spnav disables makes the crash go away:
-DCMAKE_DISABLE_FIND_PACKAGE_Spnav=TRUE -DFREECAD_USE_3DCONNEXION=Off
Steps To ReproduceBuild FreeCAD aur package on arch linux.

Try to start freecad under KDE wayland.

Observe crash.
Additional InformationThe backtrace is as follows:
#0 0x0000000000000009 in ()
#1 0x00007ffff1a44b7d in XInternAtom () at /usr/lib/libX11.so.6
0000002 0x00007ffff4b3b704 in spnav_x11_open () at /usr/lib/libspnav.so.0
0000003 0x00007ffff7659e0b in Gui::GUIApplicationNativeEventAware::initSpaceball(QMainWindow*) () at /usr/lib/freecad/lib/libFreeCADGui.so
0000004 0x00007ffff75f0685 in Gui::Application::runApplication() () at /usr/lib/freecad/lib/libFreeCADGui.so
0000005 0x000055555555845f in main ()
Tags#tobeclosed, 3dconnexion
FreeCAD Information

Activities

Kunda1

2019-03-20 18:49

administrator   ~0012931

Please always post your Help > About FreeCAD > Copy to clipboard info whenever you ask for help or open a ticket

Avenger

2019-03-20 20:23

reporter   ~0012934

Getting that info was kind of difficult, due to the crash during startup.

However, here is a copy of the non-crashing build:

OS: Arch Linux
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16093 (Git)
Build type: Release
Branch: makepkg
Hash: 690774c0effe4fd7b8d2b5e2fb2b8c8d145e21ce
Python version: 3.7.2
Qt version: 5.12.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United States (en_US)

Kunda1

2019-03-26 10:06

administrator   ~0012958

@wmayer please weigh in, thanks!

wmayer

2019-03-27 15:08

administrator   ~0012969

Last edited: 2019-03-27 15:09

At start-up we initialize spnav this way:

if (spnav_x11_open(QX11Info::display(), window->winId()) == -1) {
    Base::Console().Log("Couldn't connect to spacenav daemon\n");
} else {
...
On a system where no X is available I guess QX11Info::display() return null. Can you check if writing this fixes the problem?

if (!QX11Info::display()) {
    Base::Console().Log("No X window available\n");
}
else if (spnav_x11_open(QX11Info::display(), window->winId()) == -1) {
    Base::Console().Log("Couldn't connect to spacenav daemon\n");
} else {
...

FYI, the spnav API has two different function sets. The one is X11 based that we use in FreeCAD at the moment and the other one is the polling API which e.g. Blender uses. I hope that someone will start on integrating the polling API for FreeCAD too so that it works with Wayland.

Avenger

2019-03-27 22:14

reporter   ~0012970

Actually, this does not help, as QX11Info::display() is not a nullptr even though freecad is running as a native wayland window (as per the kwin debug console atleast).

wmayer

2019-04-03 10:53

administrator   ~0012985

If QX11Info::display() doesn't return null then the bug must be inside spnav_x11_open, i.e. a spnav bug.

Avenger

2019-04-03 14:37

reporter   ~0012986

I think so as well. I was able to recreate the crash in a standalone Qt application.

Seeing as this implementation has been replaced in freecad anyways, the bug should probably be closed.

Kunda1

2019-04-03 14:57

administrator   ~0012990

@Avenger does the bug need to be reported upstream?

Avenger

2019-04-03 15:27

reporter   ~0012991

I can handle that, I have a sample application that triggers the bug.

Kunda1

2019-04-04 13:09

administrator   ~0012994

@Avenger great news! Do you mind notating the URL for the upstream ticket before we close this one? Thanks!

wmayer

2019-04-04 14:02

administrator   ~0012996

Last edited: 2019-04-05 15:25

Seeing as this implementation has been replaced in freecad anyways, the bug should probably be closed.
There has been done some refactoring work for v0.19 but at the moment spnav_x11_open is still used.

The next step would be to use spanav's polling API as Blender does it too and therefore we would use spnav_open, instead.

Avenger

2019-04-04 17:38

reporter   ~0012997

After doing some reading on this problem, it seems that this is a FreeCAD issue after all (or maybe a Qt one). See this blog post:

https://blog.martin-graesslin.com/blog/2015/07/porting-qt-applications-to-wayland/

It seems that QX11Info::display() returns the wayland display when run on wayland, so it will be cast to the wrong type of pointer once spnav tries to use it. A solution is also presented in that blog post.

wmayer

2019-04-05 15:46

administrator   ~0012999

For v0.19:
https://github.com/FreeCAD/FreeCAD/commit/870ad71f9905d6d3e7c0d12b7858142848d513f9

For v0.18:
https://github.com/FreeCAD/FreeCAD/commit/0dc75267fee2af948c3085002a2cc61758cc5b30

Related Changesets

FreeCAD: releases/FreeCAD-0-18 0dc75267

2019-04-05 15:43:53

wmayer

Details Diff
fixes 0003913: libspnav crash on linux wayland during startup Affected Issues
0003913
mod - src/Gui/GuiApplicationNativeEventAware.cpp Diff File

Issue History

Date Modified Username Field Change
2019-03-20 13:56 Avenger New Issue
2019-03-20 18:49 Kunda1 Note Added: 0012931
2019-03-20 18:50 Kunda1 Status new => feedback
2019-03-20 20:23 Avenger Note Added: 0012934
2019-03-20 20:23 Avenger Status feedback => new
2019-03-26 10:06 Kunda1 Note Added: 0012958
2019-03-26 10:06 Kunda1 Tag Attached: 3dconnexion
2019-03-26 10:07 Kunda1 Target Version => 0.19
2019-03-27 15:08 wmayer Note Added: 0012969
2019-03-27 15:09 wmayer Note Edited: 0012969
2019-03-27 15:09 wmayer Note Edited: 0012969
2019-03-27 22:14 Avenger Note Added: 0012970
2019-04-03 10:53 wmayer Note Added: 0012985
2019-04-03 14:37 Avenger Note Added: 0012986
2019-04-03 14:57 Kunda1 Note Added: 0012990
2019-04-03 14:57 Kunda1 Tag Attached: #tobeclosed
2019-04-03 15:27 Avenger Note Added: 0012991
2019-04-04 13:09 Kunda1 Status new => feedback
2019-04-04 13:09 Kunda1 Note Added: 0012994
2019-04-04 14:02 wmayer Note Added: 0012996
2019-04-04 17:38 Avenger Note Added: 0012997
2019-04-04 17:38 Avenger Status feedback => new
2019-04-05 15:25 wmayer Note Edited: 0012996
2019-04-05 15:46 wmayer Assigned To => wmayer
2019-04-05 15:46 wmayer Status new => closed
2019-04-05 15:46 wmayer Resolution open => fixed
2019-04-05 15:46 wmayer Fixed in Version => 0.18
2019-04-05 15:46 wmayer Note Added: 0012999
2019-07-29 15:01 Kunda1 Changeset attached => FreeCAD releases/FreeCAD-0-18 0dc75267