MantisBT - VTK
View Issue Details
0016009VTK(No Category)public2016-02-23 05:592016-08-12 09:55
Elvis Stansvik 
Kitware Robot 
normalminorhave not tried
closedmoved 
6.2.0 
 
TBD
crash
0016009: Segmentation fault when importing VTK 6.2 + PyQt4 on Ubuntu
With

    python-qt4 (4.11.4+dfsg-1build3)
    python-vtk6 (6.2.0+dfsg1-4ubuntu5)

installed on an Ubuntu 15.10 system, the tiny snippet

from PyQt4.QtGui import QApplication, QMainWindow

# This program segfaults, but uncomment this line => no segfault.
from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor

import sys

app = QApplication(sys.argv)

produces a segmentation fault on start-up. If the import of QVTKRenderWindowInteractor is removed, it no longer segfaults.

The backtrace is:

#0 0x00007fff93d9bd4e in ?? () from /usr/lib/libkdecore.so.5
#1 0x00007ffff7de960a in call_init (l=<optimized out>, argc=argc@entry=2, argv=argv@entry=0x7fffffffddf8, env=env@entry=0x7fffffffde10) at dl-init.c:72
#2 0x00007ffff7de971b in call_init (env=<optimized out>, argv=<optimized out>, argc=<optimized out>, l=<optimized out>) at dl-init.c:30
#3 _dl_init (main_map=main_map@entry=0x10c4470, argc=2, argv=0x7fffffffddf8, env=0x7fffffffde10) at dl-init.c:120
#4 0x00007ffff7dee5d7 in dl_open_worker (a=a@entry=0x7fffffffc508) at dl-open.c:579
#5 0x00007ffff7de94b4 in _dl_catch_error (objname=objname@entry=0x7fffffffc4f8, errstring=errstring@entry=0x7fffffffc500, mallocedp=mallocedp@entry=0x7fffffffc4f7, operate=operate@entry=0x7ffff7dee0f0 <dl_open_worker>, args=args@entry=0x7fffffffc508) at dl-error.c:187
#6 0x00007ffff7ded9f3 in _dl_open (file=0x10d6638 "/usr/lib/kde4/plugins/styles/breeze.so", mode=-2147483647, caller_dlopen=0x7ffff4f08cd6, nsid=-2, argc=<optimized out>, argv=<optimized out>, env=0x7fffffffde10) at dl-open.c:663
#7 0x00007ffff75edfc9 in dlopen_doit (a=a@entry=0x7fffffffc720) at dlopen.c:66
#8 0x00007ffff7de94b4 in _dl_catch_error (objname=0x98b920, errstring=0x98b928, mallocedp=0x98b918, operate=0x7ffff75edf70 <dlopen_doit>, args=0x7fffffffc720) at dl-error.c:187
0000009 0x00007ffff75ee62d in _dlerror_run (operate=operate@entry=0x7ffff75edf70 <dlopen_doit>, args=args@entry=0x7fffffffc720) at dlerror.c:163
#10 0x00007ffff75ee061 in __dlopen (file=<optimized out>, mode=<optimized out>) at dlopen.c:87
0000011 0x00007ffff4f08cd6 in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#12 0x00007ffff4f0307d in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#13 0x00007ffff4f0370b in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#14 0x00007ffff4efc066 in QFactoryLoader::instance(QString const&) const () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#15 0x00007ffff575317d in QStyleFactory::create(QString const&) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#16 0x00007ffff54479ce in QApplication::style() () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#17 0x00007ffff54b910a in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#18 0x00007ffff54bcc83 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#19 0x00007ffff5447fa2 in QApplicationPrivate::construct(_XDisplay*, unsigned long, unsigned long) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#20 0x00007ffff544824f in QApplication::QApplication(int&, char**, int) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#21 0x00007ffff64fbfae in sipQApplication::sipQApplication (this=0xba80d0, a0=<optimized out>, a1=<optimized out>) at sipQtGuipart9.cpp:36106
#22 0x00007ffff64fc196 in init_type_QApplication (sipSelf=0x7ffff1136938, sipArgs=<optimized out>, sipKwds=0x0, sipUnused=<optimized out>, sipParseErr=<optimized out>) at /build/python-qt4-DPZMhZ/python-qt4-4.11.4+dfsg/sip/QtGui/qapplication.sip:901
#23 0x00007ffff16901cb in sipSimpleWrapper_init (self=0x7ffff1136938, args=(['test.py'],), kwds=0x0) at siplib.c:9702
#24 0x00000000004a9efb in type_call.lto_priv () at ../Objects/typeobject.c:745
#25 0x00000000004bf3cc in PyObject_Call (kw=0x0, arg=(['test.py'],), func=<PyQt4.QtCore.pyqtWrapperType at remote 0xac4880>) at ../Objects/abstract.c:2529
#26 do_call (nk=<optimized out>, na=<optimized out>, pp_stack=0x7fffffffd9b0, func=<PyQt4.QtCore.pyqtWrapperType at remote 0xac4880>) at ../Python/ceval.c:4574
#27 call_function (oparg=<optimized out>, pp_stack=0x7fffffffd9b0) at ../Python/ceval.c:4379
#28 PyEval_EvalFrameEx () at ../Python/ceval.c:2993
#29 0x00000000004b7986 in PyEval_EvalCodeEx () at ../Python/ceval.c:3588
#30 0x00000000004e8f3f in PyEval_EvalCode (
    locals={'QMainWindow': <PyQt4.QtCore.pyqtWrapperType at remote 0xb0d900>, 'QVTKRenderWindowInteractor': <PyQt4.QtCore.pyqtWrapperType at remote 0xba7cc0>, '__builtins__': <module at remote 0x7ffff7f79b08>, '__file__': 'test.py', 'QApplication': <PyQt4.QtCore.pyqtWrapperType at remote 0xac4880>, '__package__': None, 'sys': <module at remote 0x7ffff7f79bb0>, '__name__': '__main__', '__doc__': None},
    globals={'QMainWindow': <PyQt4.QtCore.pyqtWrapperType at remote 0xb0d900>, 'QVTKRenderWindowInteractor': <PyQt4.QtCore.pyqtWrapperType at remote 0xba7cc0>, '__builtins__': <module at remote 0x7ffff7f79b08>, '__file__': 'test.py', 'QApplication': <PyQt4.QtCore.pyqtWrapperType at remote 0xac4880>, '__package__': None, 'sys': <module at remote 0x7ffff7f79bb0>, '__name__': '__main__', '__doc__': None}, co=0x7ffff7edfe30) at ../Python/ceval.c:669
#31 run_mod.lto_priv () at ../Python/pythonrun.c:1370
#32 0x00000000004e3b02 in PyRun_FileExFlags () at ../Python/pythonrun.c:1356
#33 0x00000000004e22e6 in PyRun_SimpleFileExFlags () at ../Python/pythonrun.c:948
#34 0x0000000000490fe1 in Py_Main () at ../Modules/main.c:640
#35 0x00007ffff7811a40 in __libc_start_main (main=0x4909f0 <main>, argc=2, argv=0x7fffffffddf8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdde8) at libc-start.c:289
#36 0x0000000000490919 in _start ()

I'm not sure what is happening here. If I try the small example at

   http://www.vtk.org/Wiki/VTK/Examples/Python/Widgets/EmbedPyQt [^]

I get a different backtrace:

#0 0x00007fff97a2885e in _GLOBAL__sub_I_qpycore_classinfo.cpp () from /usr/lib/python2.7/dist-packages/PyQt4/QtCore.so
#1 0x00007ffff7de960a in call_init (l=<optimized out>, argc=argc@entry=2, argv=argv@entry=0x7fffffffddf8, env=env@entry=0x7fffffffde10) at dl-init.c:72
#2 0x00007ffff7de971b in call_init (env=<optimized out>, argv=<optimized out>, argc=<optimized out>, l=<optimized out>) at dl-init.c:30
#3 _dl_init (main_map=main_map@entry=0x9e8d10, argc=2, argv=0x7fffffffddf8, env=0x7fffffffde10) at dl-init.c:120
#4 0x00007ffff7dee5d7 in dl_open_worker (a=a@entry=0x7fffffffd1d8) at dl-open.c:579
#5 0x00007ffff7de94b4 in _dl_catch_error (objname=objname@entry=0x7fffffffd1c8, errstring=errstring@entry=0x7fffffffd1d0, mallocedp=mallocedp@entry=0x7fffffffd1c7, operate=operate@entry=0x7ffff7dee0f0 <dl_open_worker>, args=args@entry=0x7fffffffd1d8) at dl-error.c:187
#6 0x00007ffff7ded9f3 in _dl_open (file=0xee42e0 "/usr/lib/python2.7/dist-packages/PyQt4/QtCore.so", mode=-2147483646, caller_dlopen=0x51a359 <_PyImport_GetDynLoadFunc+233>, nsid=-2, argc=<optimized out>, argv=<optimized out>, env=0x7fffffffde10) at dl-open.c:663
#7 0x00007ffff75edfc9 in dlopen_doit (a=a@entry=0x7fffffffd3f0) at dlopen.c:66
#8 0x00007ffff7de94b4 in _dl_catch_error (objname=0x9a1650, errstring=0x9a1658, mallocedp=0x9a1648, operate=0x7ffff75edf70 <dlopen_doit>, args=0x7fffffffd3f0) at dl-error.c:187
0000009 0x00007ffff75ee62d in _dlerror_run (operate=operate@entry=0x7ffff75edf70 <dlopen_doit>, args=args@entry=0x7fffffffd3f0) at dlerror.c:163
#10 0x00007ffff75ee061 in __dlopen (file=<optimized out>, mode=<optimized out>) at dlopen.c:87
0000011 0x000000000051a359 in _PyImport_GetDynLoadFunc () at ../Python/dynload_shlib.c:140
#12 0x0000000000519eb4 in _PyImport_LoadDynamicModule () at ../Python/importdl.c:42
#13 0x00000000004a2891 in import_submodule () at ../Python/import.c:2704
#14 0x00000000004a7545 in ensure_fromlist () at ../Python/import.c:2610
#15 0x00000000004a1cc8 in import_module_level.isra.3 (level=-1, fromlist=('QtCore', 'QtGui'), globals=<optimized out>, name=<optimized out>) at ../Python/import.c:2273
#16 PyImport_ImportModuleLevel () at ../Python/import.c:2292
#17 0x00000000004a4834 in builtin___import__ () at ../Python/bltinmodule.c:49
#18 0x00000000004a45de in PyObject_Call () at ../Objects/abstract.c:2529
#19 0x00000000004c3e40 in PyEval_CallObjectWithKeywords () at ../Python/ceval.c:4225
#20 0x00000000004c2a38 in PyEval_EvalFrameEx () at ../Python/ceval.c:2628
#21 0x00000000004b7986 in PyEval_EvalCodeEx () at ../Python/ceval.c:3588
#22 0x00000000004e8f3f in PyEval_EvalCode (locals={'vtk': <module at remote 0x7ffff7eb70f8>, '__builtins__': <module at remote 0x7ffff7f79b08>, '__file__': 'test2.py', '__package__': None, 'sys': <module at remote 0x7ffff7f79bb0>, '__name__': '__main__', '__doc__': None},
    globals={'vtk': <module at remote 0x7ffff7eb70f8>, '__builtins__': <module at remote 0x7ffff7f79b08>, '__file__': 'test2.py', '__package__': None, 'sys': <module at remote 0x7ffff7f79bb0>, '__name__': '__main__', '__doc__': None}, co=0x7ffff7ee8db0) at ../Python/ceval.c:669
#23 run_mod.lto_priv () at ../Python/pythonrun.c:1370
#24 0x00000000004e3b02 in PyRun_FileExFlags () at ../Python/pythonrun.c:1356
#25 0x00000000004e22e6 in PyRun_SimpleFileExFlags () at ../Python/pythonrun.c:948
#26 0x0000000000490fe1 in Py_Main () at ../Modules/main.c:640
#27 0x00007ffff7811a40 in __libc_start_main (main=0x4909f0 <main>, argc=2, argv=0x7fffffffddf8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdde8) at libc-start.c:289
#28 0x0000000000490919 in _start ()

You can reproduce the segmentation fault with the first tiny example by saving it to test.py, then, with a Dockerfile containing

FROM ubuntu:15.10
MAINTAINER Elvis Stansvik

RUN apt-get update
RUN apt-get install -yy python-qt4 python-vtk6

COPY test.py test.py

in the same directory, run:

$ docker build -t test-vtk6-qt:latest .

to build an image test-vtk6-qt:latest, followed by:

$ xhost +local:
$ docker run -it -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev/shm:/dev/shm --device=/dev/dri test-vtk6-qt:latest /bin/bash
root@5a9c35379d96:/# python test.py
Segmentation fault (core dumped)

to reproduce the segmentation fault.
No tags attached.
? test.py (233) 2016-03-29 03:07
https://www.vtk.org/Bug/file/10058/test.py
? Dockerfile (133) 2016-03-29 03:07
https://www.vtk.org/Bug/file/10059/Dockerfile
Issue History
2016-02-23 05:59Elvis StansvikNew Issue
2016-02-23 06:06Elvis StansvikNote Added: 0035763
2016-02-23 08:10Elvis StansvikNote Added: 0035764
2016-02-23 08:12Elvis StansvikNote Added: 0035765
2016-03-24 18:24David GobbiNote Added: 0035860
2016-03-29 03:05Elvis StansvikNote Added: 0035863
2016-03-29 03:07Elvis StansvikFile Added: test.py
2016-03-29 03:07Elvis StansvikFile Added: Dockerfile
2016-03-29 03:08Elvis StansvikNote Added: 0035864
2016-03-29 23:21David GobbiNote Added: 0035866
2016-04-03 20:17David GobbiNote Added: 0035870
2016-08-12 09:55Kitware RobotNote Added: 0037457
2016-08-12 09:55Kitware RobotStatusbacklog => closed
2016-08-12 09:55Kitware RobotResolutionopen => moved
2016-08-12 09:55Kitware RobotAssigned To => Kitware Robot

Notes
(0035763)
Elvis Stansvik   
2016-02-23 06:06   
I should note: You'll need a recent Docker to follow the steps to reproduce above.
(0035764)
Elvis Stansvik   
2016-02-23 08:10   
I was able to get a core dump inside the container, and noticed that when running in Docker, the backtrace is actually different yet again (detailed backtrace this time since I installed some -dbg packages):

#0 QBasicAtomicInt::ref (this=<optimized out>) at ../../../../include/QtCore/../../src/corelib/arch/qatomic_x86_64.h:121
#1 QList<QString>::QList (this=0x7fffb9c8f580) at ../../../../include/QtCore/../../src/corelib/tools/qlist.h:121
#2 QStringList::QStringList (i=..., this=0x7fffb9c8f580) at ../../../../include/QtCore/../../src/corelib/tools/qstringlist.h:70
#3 QMultiInputContextPlugin::keys (this=<optimized out>) at qmultiinputcontextplugin.cpp:76
#4 0x00007f9752e8e8a5 in QFactoryLoader::updateDir (this=this@entry=0x2262990, pluginDir=..., settings=...) at plugin/qfactoryloader.cpp:181
#5 0x00007f9752e8f95d in QFactoryLoader::update (this=this@entry=0x2262990) at plugin/qfactoryloader.cpp:233
#6 0x00007f9752e8fbcc in QFactoryLoader::QFactoryLoader (this=0x2262990, iid=0x7f9753ad3e70 "com.trolltech.Qt.QInputContextFactoryInterface", suffix=..., cs=Qt::CaseSensitive) at plugin/qfactoryloader.cpp:121
#7 0x00007f97539b761a in loader () at inputmethod/qinputcontextfactory.cpp:85
#8 0x00007f97539b7a37 in QInputContextFactory::keys () at inputmethod/qinputcontextfactory.cpp:197
0000009 0x00007f9753446d65 in QApplicationPrivate::x11_apply_settings () at kernel/qapplication_x11.cpp:1096
#10 0x00007f975344936f in qt_set_x11_resources (font=0x0, fg=0x0, bg=0x0, button=0x0) at kernel/qapplication_x11.cpp:1170
0000011 0x00007f975344dc83 in qt_init (priv=priv@entry=0x1d748a0, display=display@entry=0x0, visual=visual@entry=0, colormap=colormap@entry=0) at kernel/qapplication_x11.cpp:2459
#12 0x00007f97533d8fa2 in QApplicationPrivate::construct (this=0x1d748a0, dpy=dpy@entry=0x0, visual=visual@entry=0, cmap=cmap@entry=0) at kernel/qapplication.cpp:842
#13 0x00007f97533d924f in QApplication::QApplication (this=0x1d76bc0, argc=@0x7f975492e56c: 1, argv=0x1d88160, _internal=17041414) at kernel/qapplication.cpp:741
#14 0x00007f975448cfae in sipQApplication::sipQApplication (this=0x1d76bc0, a0=<optimized out>, a1=<optimized out>) at sipQtGuipart9.cpp:36106
#15 0x00007f975448d196 in init_type_QApplication (sipSelf=0x7f974f0c6938, sipArgs=<optimized out>, sipKwds=0x0, sipUnused=<optimized out>, sipParseErr=<optimized out>) at /build/python-qt4-DPZMhZ/python-qt4-4.11.4+dfsg/sip/QtGui/qapplication.sip:901
#16 0x00007f974f6211cb in sipSimpleWrapper_init (self=0x7f974f0c6938, args=(['test.py'],), kwds=0x0) at siplib.c:9702
#17 0x00000000004a9efb in type_call.lto_priv () at ../Objects/typeobject.c:745
#18 0x00000000004bf3cc in PyObject_Call (kw=0x0, arg=(['test.py'],), func=<PyQt4.QtCore.pyqtWrapperType at remote 0x1c93360>) at ../Objects/abstract.c:2529
#19 do_call (nk=<optimized out>, na=<optimized out>, pp_stack=0x7fffb9c90df0, func=<PyQt4.QtCore.pyqtWrapperType at remote 0x1c93360>) at ../Python/ceval.c:4574
#20 call_function (oparg=<optimized out>, pp_stack=0x7fffb9c90df0) at ../Python/ceval.c:4379
#21 PyEval_EvalFrameEx () at ../Python/ceval.c:2993
#22 0x00000000004b7986 in PyEval_EvalCodeEx () at ../Python/ceval.c:3588
#23 0x00000000004e8f3f in PyEval_EvalCode (
    locals={'QMainWindow': <PyQt4.QtCore.pyqtWrapperType at remote 0x1cdc3e0>, 'QVTKRenderWindowInteractor': <PyQt4.QtCore.pyqtWrapperType at remote 0x1d767a0>, '__builtins__': <module at remote 0x7f9755a08b08>, '__file__': 'test.py', 'QApplication': <PyQt4.QtCore.pyqtWrapperType at remote 0x1c93360>, '__package__': None, 'sys': <module at remote 0x7f9755a08bb0>, '__name__': '__main__', '__doc__': None},
    globals={'QMainWindow': <PyQt4.QtCore.pyqtWrapperType at remote 0x1cdc3e0>, 'QVTKRenderWindowInteractor': <PyQt4.QtCore.pyqtWrapperType at remote 0x1d767a0>, '__builtins__': <module at remote 0x7f9755a08b08>, '__file__': 'test.py', 'QApplication': <PyQt4.QtCore.pyqtWrapperType at remote 0x1c93360>, '__package__': None, 'sys': <module at remote 0x7f9755a08bb0>, '__name__': '__main__', '__doc__': None}, co=0x7f9755933eb0) at ../Python/ceval.c:669
#24 run_mod.lto_priv () at ../Python/pythonrun.c:1370
#25 0x00000000004e3b02 in PyRun_FileExFlags () at ../Python/pythonrun.c:1356
#26 0x00000000004e22e6 in PyRun_SimpleFileExFlags () at ../Python/pythonrun.c:948
#27 0x0000000000490fe1 in Py_Main () at ../Modules/main.c:640
#28 0x00007f9755278a40 in __libc_start_main (main=0x4909f0 <main>, argc=2, argv=0x7fffb9c91238, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffb9c91228) at libc-start.c:289
#29 0x0000000000490919 in _start ()

I don't know who is to blame here, but the strange thing is that no matter what segfault (what backtrace) I can get rid of the crash by simply removing the import of the VTK class.
(0035765)
Elvis Stansvik   
2016-02-23 08:12   
But just to clarify: I can get a segfault both inside and outside Docker, so it's not just some artifact of running X11 apps inside Docker. I was just using it for isolating the problem.

It is strange that the backtraces are different though..
(0035860)
David Gobbi   
2016-03-24 18:24   
Elvis, can you attach your test.py file to the bug report?

If I could get the file, that makes it very easy for me take a peek at the code, take a guess at how complicated the problem will be, and schedule a time when I'll be in front of my linux box to try it out. (My linux box isn't an ubuntu 10.50 system, so I'll have to boot up my debian jessie virtual machine in the hopes that it is similar enough).

If I go the docker route, I'll have to invest a fair bit of time before I even get to see the program that's causing the crash.
(0035863)
Elvis Stansvik   
2016-03-29 03:05   
Hi David,

Sorry, I should have attached test.py, but like I said in the Description, it was simply:

from PyQt4.QtGui import QApplication, QMainWindow

# This program segfaults, but uncomment this line => no segfault.
from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor

import sys

app = QApplication(sys.argv)

I think the Docker way would be the most reliable way to reproduce it, if your jessie VM turns out to be too different from Ubuntu 15.10.

Thanks for looking into this!
(0035864)
Elvis Stansvik   
2016-03-29 03:08   
I attached test.py and Dockerfile, they should work with the instructions at the end of the Description.
(0035866)
David Gobbi   
2016-03-29 23:21   
Hi Elvis,

Sorry for the confusion (on my part, I mean). I should have read the bug description more carefully, I thought that it only gave a short code segment and not the complete program.

I can take a look this weekend.

 - David
(0035870)
David Gobbi   
2016-04-03 20:17   
My jessie VM only has VTK 5.8 and 6.1, both of which ran test.py without problems. It also ran with my own build of vtk-master.

I installed docker and ran the "docker build" command, but I killed the build when it started downloading hundreds of packages... I wasn't sure my root partition was large enough.

Can you narrow down the problem by identifying what part of QVTKRenderWindowInteractor.py is responsible?
(0037457)
Kitware Robot   
2016-08-12 09:55   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current VTK Issues page linked in the banner at the top of this page.