[SOLVED] Segmentation fault at exit of gui

Post here to get support
mlundh
Beginner
Posts: 18
Joined: Fri Nov 28, 2014 5:31 pm

[SOLVED] Segmentation fault at exit of gui

Post by mlundh »

I am eagerly awaiting my crazyfile 2, and in the mean time I'm trying to get to know the PC side of the copter. I can start and use the gui application, but when i close it I always seem to get a segmentation fault. Have anyone else encountered this problem? I am running Ubuntu 14.04.

Thanks!
Last edited by mlundh on Sun Dec 28, 2014 3:40 pm, edited 2 times in total.
whoenig
Expert
Posts: 395
Joined: Mon Oct 27, 2014 2:55 am

Re: Segmentation fault at exit of gui

Post by whoenig »

This is definitely not normal. In fact, because it is written in python it should be technically impossible to segfault... You can try running it with gdb to get a full stack trace on where the crash is happening and post the stack here.
mlundh
Beginner
Posts: 18
Joined: Fri Nov 28, 2014 5:31 pm

Re: Segmentation fault at exit of gui

Post by mlundh »

yes, it it a bit strange, but I assume the problem has something to do with my setup, dependencies or something like... Anyway, i managed to get gdb running (after installing python2.7-dbg) and got the following trace:

Code: Select all

Program received signal SIGSEGV, Segmentation fault.
__GI___pthread_mutex_lock (mutex=0x1bf2900) at ../nptl/pthread_mutex_lock.c:66
66	../nptl/pthread_mutex_lock.c: No such file or directory.
(gdb) bt
#0  __GI___pthread_mutex_lock (mutex=0x1bf2900)
    at ../nptl/pthread_mutex_lock.c:66
#1  0x00007f0b6699b2c7 in XrmDestroyDatabase ()
   from /usr/lib/x86_64-linux-gnu/libX11.so.6
#2  0x00007f0b669837b3 in _XFreeDisplayStructure ()
   from /usr/lib/x86_64-linux-gnu/libX11.so.6
#3  0x00007f0b669714ef in XCloseDisplay ()
   from /usr/lib/x86_64-linux-gnu/libX11.so.6
#4  0x00007f0b6149cd6e in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#5  0x00007f0b61433d66 in QApplication::~QApplication() ()
   from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#6  0x00007f0b624163a9 in ?? ()
   from /usr/lib/python2.7/dist-packages/PyQt4/QtGui.so
#7  0x00007f0b62443372 in ?? ()
   from /usr/lib/python2.7/dist-packages/PyQt4/QtGui.so
#8  0x00007f0b5eae3a26 in ?? () from /usr/lib/python2.7/dist-packages/sip.so
#9  0x00007f0b5eae4d09 in ?? () from /usr/lib/python2.7/dist-packages/sip.so
#10 0x00000000004d94bb in subtype_dealloc.25589 (
    self=<QApplication at remote 0x7f0b50140938>)
    at ../Objects/typeobject.c:1030
#11 0x000000000053a573 in frame_dealloc.14878 (
    f=Frame 0x1252470, for file /usr/local/lib/python2.7/dist-packages/cfclient/cfclient.py, line 136, in main (main_window=<MainUI(configGroup=<QActionGroup at---Type <return> to continue, or q <return> to quit---
 remote 0x7f0b50093c30>, actionOptions=<QAction at remote 0x7f0b500930e8>, toolboxesMenuItem=<QAction at remote 0x7f0b50085e90>, tabs=<QTabWidget at remote 0x7f0b50085180>, actionSelect_input_device=<QAction at remote 0x7f0b50085d60>, _bootloader_dialog=<BootloaderDialog(pushButton_2=<QPushButton at remote 0x7f0b5006d770>, helper=<PluginHelper(menu=None, logConfigReader=<LogConfigReader(dsList=[], _cf=<Crazyflie(_answer_patterns={}, connected_ts=None, incoming=<_IncomingPacketHandler(_Thread__ident=139685931202304, _Thread__block=<_Condition(_Verbose__verbose=False, _Condition__lock=<thread.lock at remote 0x7f0b5295f490>, acquire=<built-in method acquire of thread.lock object at remote 0x7f0b5295f490>, _Condition__waiters=[], release=<built-in method release of thread.lock object at remote 0x7f0b5295f490>) at remote 0x7f0b50095250>, _Thread__name='Thread-1',...(truncated)) at ../Objects/frameobject.c:460
#12 0x0000000000534323 in tb_dealloc.45974 (tb=0x7f0b4003f830)
    at ../Python/traceback.c:28
#13 0x00000000005342f9 in tb_dealloc.45974 (tb=0x7f0b4003f878)
    at ../Python/traceback.c:27
#14 0x000000000042fcb2 in handle_system_exit () at ../Python/pythonrun.c:1150
#15 0x000000000042ec32 in PyErr_PrintEx (
    set_sys_last_vars=set_sys_last_vars@entry=1) at ../Python/pythonrun.c:1161
#16 0x0000000000469f2f in PyErr_Print () at ../Python/pythonrun.c:1064
#17 PyRun_SimpleFileExFlags (fp=<optimized out>, fp@entry=0x118fcd0, 
    filename=<optimized out>, 
    filename@entry=0x7fff8e616250 "/usr/local/bin/cfclient", 
---Type <return> to continue, or q <return> to quit---
    closeit=closeit@entry=1, flags=flags@entry=0x7fff8e614350)
    at ../Python/pythonrun.c:952
#18 0x000000000046a018 in PyRun_AnyFileExFlags (fp=fp@entry=0x118fcd0, 
    filename=filename@entry=0x7fff8e616250 "/usr/local/bin/cfclient", 
    closeit=closeit@entry=1, flags=flags@entry=0x7fff8e614350)
    at ../Python/pythonrun.c:752
#19 0x000000000046ab81 in Py_Main (argc=<optimized out>, argv=0x7fff8e614508)
    at ../Modules/main.c:640
#20 0x00007f0b69775ec5 in __libc_start_main (main=0x46ac3f <main>, argc=2, 
    argv=0x7fff8e614508, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7fff8e6144f8) at libc-start.c:287
#21 0x000000000057497e in _start ()
What do you think? I had to install numpy, PySDL2-0.9.3 and pyqtgraph separatly from github (clone, install etc.) since i could not find them in apt.

EDIT:

I also found that i got a segfault when I tried to enter the "configure device mapping" page, if I did not change mapping first(?). The backtrace from that event:

Code: Select all

[New Thread 0x7f940bfff700 (LWP 3723)]

Program received signal SIGSEGV, Segmentation fault.
0x00007f9438389bd8 in SDL_SYS_JoystickClose (joystick=joystick@entry=0x28dfec0)
    at /build/buildd/libsdl2-2.0.2+dfsg1/src/joystick/linux/SDL_sysjoystick.c:845
845	/build/buildd/libsdl2-2.0.2+dfsg1/src/joystick/linux/SDL_sysjoystick.c: No such file or directory.
(gdb) bt
#0  0x00007f9438389bd8 in SDL_SYS_JoystickClose (
    joystick=joystick@entry=0x28dfec0)
    at /build/buildd/libsdl2-2.0.2+dfsg1/src/joystick/linux/SDL_sysjoystick.c:845
#1  0x00007f943831596e in SDL_JoystickClose_REAL (joystick=0x28dfec0)
    at /build/buildd/libsdl2-2.0.2+dfsg1/src/joystick/SDL_joystick.c:416
#2  0x00007f9438bf0adc in ffi_call_unix64 ()
   from /usr/lib/x86_64-linux-gnu/libffi.so.6
#3  0x00007f9438bf040c in ffi_call ()
   from /usr/lib/x86_64-linux-gnu/libffi.so.6
#4  0x00007f9438e075fe in _call_function_pointer (argcount=1, 
    resmem=0x7fff00691890, restype=<optimized out>, atypes=<optimized out>, 
    avalues=0x7fff00691870, pProc=0x7f943830bf50 <SDL_JoystickClose>, 
    flags=4353) at /build/buildd/python2.7-2.7.6/Modules/_ctypes/callproc.c:836
#5  _ctypes_callproc (pProc=pProc@entry=0x7f943830bf50 <SDL_JoystickClose>, 
    argtuple=argtuple@entry=(<LP_SDL_Joystick at remote 0x7f942102d9e0>,), 
    flags=4353, 
    argtypes=argtypes@entry=(<built-in method from_param of _ctypes.PyCPointerType object at remote 0x1e37c70>,), restype=restype@entry=None, 
    checker=checker@entry=0x0)
    at /build/buildd/python2.7-2.7.6/Modules/_ctypes/callproc.c:1183
#6  0x00007f9438e08f9e in PyCFuncPtr_call (self=<optimized out>, 
    inargs=<optimized out>, kwds=<optimized out>)
---Type <return> to continue, or q <return> to quit---q

My guess is that there is something strange going on with the SDL2 lib in my setup. I checked the cfclient repo, and it seems like it is a new dependency?
whoenig
Expert
Posts: 395
Joined: Mon Oct 27, 2014 2:55 am

Re: Segmentation fault at exit of gui

Post by whoenig »

PySDL dependency seems to be added just a day ago: https://github.com/bitcraze/crazyflie-c ... fd1545fe90. I didn't update yet so I am not sure about your second error. However, the first one looks like you might try to use Qt4 and Qt5 at the same time. When you compiled pyqtgraph, did you compile it against Qt4 or Qt5? You need to use Qt4 because the rest of the UI is using Qt4 as well. I did not compile it myself, but installed the *.deb from the webpage (http://www.pyqtgraph.org/downloads/pyth ... -1_all.deb), which works fine with the Crazyflie Client on Ubuntu 14.04.

For the second one: Try to sync to an older version and see if your issue goes away.
mlundh
Beginner
Posts: 18
Joined: Fri Nov 28, 2014 5:31 pm

Re: Segmentation fault at exit of gui

Post by mlundh »

Thank you for your help! I have tried to uninstall all deps. and reinstall them, using the *.deb package you suggested and pySDL2 via pip install, but no luck. It behaves just like before. I do have Qt5 installed on my machine, I am not really sure why though :) Do you think this cause any problems?

I did also do a checkout of an older version of the cfclient, and then no more segfaults! It seems like there is something strange going on with the SDL2 lib, or python wrapper. I am currently using SHA1 ID: 56fda6e79936a1f644a4ff0ad05e1adc58c8cbbc

I installed everything on my mac too, and there it works fine with the latest version (even though there was a slight version problem with two dep. libraries, but using a pre-release version fixed that)!
whoenig
Expert
Posts: 395
Joined: Mon Oct 27, 2014 2:55 am

Re: Segmentation fault at exit of gui

Post by whoenig »

Qt4 and Qt5 can be installed at the same time and this is also normal at this point (a few apps switched to Qt5, but many remain using Qt4). However, one application can not use Qt4 and Qt5 at the same time - this causes strange behavior including segfaults. I think you don't need to do anything here:-)

I might try switching to the latest client on my system. However, I would assume that it was just not properly tested and that there might be a general issue on Ubuntu.
mlundh
Beginner
Posts: 18
Joined: Fri Nov 28, 2014 5:31 pm

Re: Segmentation fault at exit of gui

Post by mlundh »

Again, thanks four your help :) Let me know how it goes with the latest version of cfclient for you, it would be interesting to know if its just my system or a general problem. My guess is that they will publish some updates when the new file starts to ship...
dbrgn
Member
Posts: 51
Joined: Tue Dec 16, 2014 9:42 pm

Re: Segmentation fault at exit of gui

Post by dbrgn »

Looks like I'm experiencing the same problem on Arch Linux:

https://github.com/bitcraze/crazyflie-c ... issues/134
mighty_falcon
Beginner
Posts: 3
Joined: Wed Dec 17, 2014 6:44 am

Re: Segmentation fault at exit of gui

Post by mighty_falcon »

Just got my crazyflie 2 and running into a similar issue. I am running into this error when scanning for the crazyflie. The first time i opened the client it worked but then I compiled libusb manually and this issue started happening. The UI quits with the following being printed in the console:

2014-12-16 22:29:54.565 Python[600:6688] _createMenuRef called with existing principal MenuRef already associated with menu
2014-12-16 22:29:54.566 Python[600:6688] (
0 CoreFoundation 0x00007fff895eb64c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff868166de objc_exception_throw + 43
2 CoreFoundation 0x00007fff895eb4fd +[NSException raise:format:] + 205
3 AppKit 0x00007fff8722b315 -[NSCarbonMenuImpl _createMenuRef] + 62
4 AppKit 0x00007fff8722ac66 -[NSCarbonMenuImpl _instantiateCarbonMenu] + 139
5 AppKit 0x00007fff872294d2 -[NSApplication finishLaunching] + 947
6 AppKit 0x00007fff87228da1 -[NSApplication run] + 128
7 QtGui 0x000000010e005f18 _ZN19QEventDispatcherMac13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE + 1522
8 QtCore 0x000000010d4d56f1 _ZN10QEventLoop13processEventsE6QFlagsINS_17ProcessEventsFlagEE + 77
9 QtCore 0x000000010d4d5870 _ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE + 370
10 QtCore 0x000000010d4d851f _ZN16QCoreApplication4execEv + 199
11 QtGui.so 0x000000010d7d4fca _ZL23meth_QApplication_exec_P7_objectS0_ + 80
12 Python 0x000000010c90962c PyEval_EvalFrameEx + 14394
13 Python 0x000000010c90c46a fast_function + 262
14 Python 0x000000010c909246 PyEval_EvalFrameEx + 13396
15 Python 0x000000010c905bbe PyEval_EvalCodeEx + 1409
16 Python 0x000000010c905637 PyEval_EvalCode + 54
17 Python 0x000000010c925926 run_mod + 53
18 Python 0x000000010c9259c9 PyRun_FileExFlags + 133
19 Python 0x000000010c925566 PyRun_SimpleFileExFlags + 769
20 Python 0x000000010c936c9b Py_Main + 3051
21 libdyld.dylib 0x00007fff82dca5c9 start + 1
)
Fatal Python error: (pygame parachute) Segmentation Fault
Abort trap: 6

This happen if I have the crazyradio 2 connected or disconnected. Any thoughts?
Malte
Beginner
Posts: 13
Joined: Thu Nov 13, 2014 3:57 pm

Re: Segmentation fault at exit of gui

Post by Malte »

I have the same issue on an opensuse 13.1.
Exactly like you said, by starting "configure device mapping" and by closing the gui i get a segmentation fault.
A (bad) workaround for me is to change the mappings and then start "configure device mapping" this works.
Post Reply