pcbnew crashes on start compiled with KICAD_SCRIPTING_WXPYTHON=ON

Bug #1299217 reported by Ruediger Kluge on 2014-03-28
64
This bug affects 11 people
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Undecided
Unassigned

Bug Description

pcbnew crashes on start compiled with KICAD_SCRIPTING_WXPYTHON=ON

Hi,

Operating system is Linux Kubuntu 13.10
I compiled kicad 2014-03-27 BZR 4770 with different options:

KICAD_SCRIPTING_WXPYTHON=ON
KICAD_SCRIPTING_WXPYTHON=OFF

1) Start KiCAD
2) Start Pcbnew

pcbnew *crashes* on start when it is compiled with KICAD_SCRIPTING_WXPYTHON=ON

Application: kicad
Version: (2014-03-27 BZR 4770)-product Release build
wxWidgets: Version 2.8.12 (release,Unicode,compiler with C++ ABI 1002,GCC 4.8.1,wx containers,compatible with 2.6)
Platform: Linux 3.11.0-18-generic x86_64, 64 bit, Little endian, wxGTK
Boost version: 1.54.0
         USE_WX_GRAPHICS_CONTEXT=OFF
         USE_WX_OVERLAY=OFF
         KICAD_SCRIPTING=ON
         KICAD_SCRIPTING_MODULES=ON
         KICAD_SCRIPTING_WXPYTHON=ON
         USE_FP_LIB_TABLE=HARD_CODED_ON
         BUILD_GITHUB_PLUGIN=ON

pcbnew *crashes not* on start when it is compiled with KICAD_SCRIPTING_WXPYTHON=OFF

Application: kicad
Version: (2014-03-27 BZR 4770)-product Release build
wxWidgets: Version 2.8.12 (release,Unicode,compiler with C++ ABI 1002,GCC 4.8.1,wx containers,compatible with 2.6)
Platform: Linux 3.11.0-18-generic x86_64, 64 bit, Little endian, wxGTK
Boost version: 1.54.0
         USE_WX_GRAPHICS_CONTEXT=OFF
         USE_WX_OVERLAY=OFF
         KICAD_SCRIPTING=ON
         KICAD_SCRIPTING_MODULES=ON
         KICAD_SCRIPTING_WXPYTHON=OFF
         USE_FP_LIB_TABLE=HARD_CODED_ON
         BUILD_GITHUB_PLUGIN=ON

The kicad version downloaded from ppa on 27.03.14 and installed with the package managent has the same problem, pcbnew *crashes* on start.
I installed on two different computers.

If I start pcbnew with the console, I get the following messages:

~$ /usr/bin/pcbnew
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/__init__.py", line 45, in <module>
    from wx._core import *
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py", line 4, in <module>
    import _core_
ImportError: /usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_core_.so: undefined symbol: PyExc_ValueError
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 64, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python2.7/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python2.7/dist-packages/apport/report.py", line 16, in <module>
    from xml.parsers.expat import ExpatError
  File "/usr/lib/python2.7/xml/parsers/expat.py", line 4, in <module>
    from pyexpat import *
ImportError: /usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so: undefined symbol: _Py_ZeroStruct

Original exception was:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/__init__.py", line 45, in <module>
    from wx._core import *
  File "/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py", line 4, in <module>
    import _core_
ImportError: /usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_core_.so: undefined symbol: PyExc_ValueError
Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 14: reading configurations from ~/.fonts.conf is deprecated.
Segmentation fault (core dumped)

Ruediger

Thav (thavilden) wrote :

I get the same crash on start when running packages from the PPA https://code.launchpad.net/~js-reynaud/+archive/ppa-kicad

Linux Mint 14 (Uses Ubuntu 12.10 packages)
I get this trouble with a package that I got today (0.201403281856+4774~12~ubuntu12.10.1) as well as others from up to five days ago when I first tried the PPA.

The only other reference to this kind of error appears to be this thread:
https://groups.google.com/forum/#!topic/wxpython-users/cWBabXCeEwU
which suggests a mismatch between wxWidgets and wxPython. However, I see no mismatch:

tony@olympus /usr/share/kicad/modules $ sudo dpkg -l | grep libwx
ii libwx-perl 1:0.9909-1 amd64 interface to wxWidgets cross-platform GUI toolkit
ii libwxbase2.8-0:amd64 2.8.12.1-11ubuntu3.1 amd64 wxBase library (runtime) - non-GUI support classes of wxWidgets toolkit
ii libwxbase2.8-dev 2.8.12.1-11ubuntu3.1 amd64 wxBase library (development) - non-GUI support classes of wxWidgets toolkit
ii libwxgtk2.8-0:amd64 2.8.12.1-11ubuntu3.1 amd64 wxWidgets Cross-platform C++ GUI toolkit (GTK+ runtime)
ii libwxgtk2.8-dev 2.8.12.1-11ubuntu3.1 amd64 wxWidgets Cross-platform C++ GUI toolkit (GTK+ development)
tony@olympus /usr/share/kicad/modules $ sudo dpkg -l | grep python-wxgtk
ii python-wxgtk2.8 2.8.12.1-11ubuntu3.1 amd64 wxWidgets Cross-platform C++ GUI toolkit (wxPython binding)

Nick Østergaard (nickoe) wrote :

Please retry, I think this is already fixed. http://bazaar.launchpad.net/~kicad-product-committers/kicad/product/revision/4771

Please report back if it works now.

Ruediger Kluge (ruediger-kluge) wrote :

I made the update of ppa:js-reynaud/ppa-kicad.
In the Kubuntu package management it is called 0.201403281856+4774~12~ubuntu13.10.1

pcbnew still crashes if I start with click from Kicad GUI.

The information from help -- copy version information is:

Application: kicad
Version: (2014-jan-25)-product Release build
wxWidgets: Version 2.8.12 (release,Unicode,compiler with C++ ABI 1002,GCC 4.8.1,wx containers,compatible with 2.6)
Platform: Linux 3.11.0-18-generic x86_64, 64 bit, Little endian, wxGTK
Boost version: 1.54.0
         USE_WX_GRAPHICS_CONTEXT=OFF
         USE_WX_OVERLAY=OFF
         KICAD_SCRIPTING=ON
         KICAD_SCRIPTING_MODULES=ON
         KICAD_SCRIPTING_WXPYTHON=ON
         USE_FP_LIB_TABLE=HARD_CODED_ON
         BUILD_GITHUB_PLUGIN=ON

I compiled the version 4776 and installed this time in the default installation path (not in /opt/kicad) CMAKE_INSTALL_PREFIX:PATH=/usr/local

pcbnew still crashes if I start with click from Kicad GUI.

The information from help -- copy version information is:

Application: kicad
Version: (2014-03-29 BZR 4776)-product Release build
wxWidgets: Version 2.8.12 (release,Unicode,compiler with C++ ABI 1002,GCC 4.8.1,wx containers,compatible with 2.6)
Platform: Linux 3.11.0-18-generic x86_64, 64 bit, Little endian, wxGTK
Boost version: 1.54.0
         USE_WX_GRAPHICS_CONTEXT=OFF
         USE_WX_OVERLAY=OFF
         KICAD_SCRIPTING=ON
         KICAD_SCRIPTING_MODULES=ON
         KICAD_SCRIPTING_WXPYTHON=ON
         USE_FP_LIB_TABLE=HARD_CODED_ON
         BUILD_GITHUB_PLUGIN=ON

Nick Østergaard (nickoe) wrote :

It does not crashere on my ubuntu 13.10. Do you have python-lxml installed?

Application: kicad
Version: (2014-03-29 BZR 4775)-product Release build
wxWidgets: Version 2.8.12 (release,Unicode,compiler with C++ ABI 1002,GCC 4.8.1,wx containers,compatible with 2.6)
Platform: Linux 3.11.0-18-generic x86_64, 64 bit, Little endian, wxGTK
Boost version: 1.54.0
         USE_WX_GRAPHICS_CONTEXT=OFF
         USE_WX_OVERLAY=OFF
         KICAD_SCRIPTING=OFF
         KICAD_SCRIPTING_MODULES=OFF
         KICAD_SCRIPTING_WXPYTHON=OFF
         USE_FP_LIB_TABLE=HARD_CODED_ON
         BUILD_GITHUB_PLUGIN=ON

Thav (thavilden) wrote :

No change for me running 0.201403291813+4776~12~ubuntu12.10.1 from PPA. python-lxml is installed.

Nick Østergaard (nickoe) wrote :

Ok, the python-lxml was also a wild shot. There is that undefined symbol: PyExc_ValueError that nags me.

Are you able to do "from pyexpat import *" in your python2 interpreter without the quotes succesfully?

Thav (thavilden) wrote :

I am, I get no errors importing that.

Some additional info, output of 'dpkg -l | grep -i python'
http://pastebin.com/p5hh9fBb

and output of 'dpkg -l | grep -i wx'
http://pastebin.com/kqVCArhe

In case those help at all. I'm more than happy to provide any more information you think might be useful. Thanks!

Ruediger Kluge (ruediger-kluge) wrote :

I also can do "from pyexpat import *" succesfully.

Nick Østergaard (nickoe) wrote :

I just noticed that I did not enable scripting in my build on ubuntu, so the claim that it worked for me is invalid. But I can't build with the options enabled on my ubuntu machine.

-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.5", required is "2.6")
-- Check for installed Python Interpreter -- found
-- Python module install path: /usr/lib/python2.7/dist-packages
-- Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) (Required is at least version "2.6")
-- Bazaar version control system version found.
-- Kicad Bazaar build version: (2014-03-29 BZR 4777)
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
  Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-2.8/Modules/FindSWIG.cmake:67 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  pcbnew/CMakeLists.txt:12 (find_package)

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
PYTHON_INCLUDE_DIR (ADVANCED)
   used as include directory in directory /home/foo/kicad_sources/kicad.bzr/bitmaps_png
>>bla bla bla more of theese lines<<

-- Configuring incomplete, errors occurred!

Thav (thavilden) wrote :

A github issue on an unrelated project discusses a way to make cmake see swig

`cmake -DSWIG_EXECUTABLE=/usr/bin/swig`

Hope that helps.

Thav (thavilden) wrote :

https://github.com/thp/psmoveapi/issues/5

^ forgot to post the URL in my last comment.

Dick Hollenbeck (dickelbeck) wrote :

I am offering to fix this bug as part of milestone C) of modular-kicad blueprint, but not before I get to that point.

Your options now are:

a) revert to the tagged revision "pre-kiway" and build that version.
b) disable wxPython at newer version.
c) hope someone else fixes it sooner than I intend to.

Francesco Del Degan (pr0gg3d) wrote :

Looking at it, seems that is just missing python library linking issue, because with:

LD_PRELOAD=/usr/lib/libpython2.7.so.1 pcbnew

it works for me (r4805) . Anyone can confirm?

Aurabindo J (jay-aurabind) wrote :

Yepp. I confirm.

I'm on a 64 bit Ubuntu 14.04, so its

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libpython2.7.so.1 pcbnew

Aurabindo J (jay-aurabind) wrote :

But How do I make pcbnew to launch properly when invoking from Kicad ? Is it safe to export LD_PRELOAD in /etc/profiles.d/kicad.sh ?

Nils Peter Hesse (nphesse) wrote :

Hi,

quick fix for being able to launch pcbnew properly using the KiCAD GUI (this is for Ubuntu using sudo. If you're not on Ubuntu you may have to adapt the paths and/or the usage of the sudo command):

$ PCBNEW="$(which pcbnew)"
$ sudo mv ${PCBNEW} ${PCBNEW}.bin
$ sudo gedit $PCBNEW
Replace "gedit" with your preferred text editor.
Paste the following snippet into the editor and save (please make sure the first line in the file reads "#!/bin/bash"!):

#!/bin/bash

if [ "$(uname -p)" == "x86_64" ]; then
    LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libpython2.7.so.1 pcbnew.bin
else
    LD_PRELOAD=/usr/lib/libpython2.7.so.1 pcbnew
fi

# END OF SNIPPET

$ sudo chmod +x $PCBNEW

What does this do?
First, you get the full path to the current "pcbnew" executable (which pcbnew) and save it into a variable called "PCBNEW".
Then the executable is renamed to pcbnew.bin within the same directory ("mv $PCBNEW ${PCBNEW}.bin").
After that you create a new file with the same path & name as the original pcbnew executable and write a small bash script to it which does nothing else than to execute the pcbnew.bin file (which, if you remember, is the renamed original executable) using the LD_PRELOAD environment variable to make sure the shared library gets loaded.
The last command sets the executable flag on the newly created script which enables one to execute the script as if it were a binary executable program.

After that you've renamed the original pcbnew executable and replaced it with a small script which spawns the original executable with LD_PRELOAD.

Please remember upon the next update that you may have to re-do these steps - or remove the old pcbnew.bin if the issue was fixed.

Nils Peter Hesse (nphesse) wrote :

I'm very sorry, there is a bug in the shell script. One should use this shell script instead:

#!/bin/bash

if [ "$(uname -p)" == "x86_64" ]; then
    LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libpython2.7.so.1 pcbnew.bin $@
else
    LD_PRELOAD=/usr/lib/libpython2.7.so.1 pcbnew.bin $@
fi

# END OF SNIPPET

Please note the now appended "$@" when executing pcbnew and the now appended ".bin" for the 32bit command.

The first one is needed for forwarding command line parameters to the pcbnew executable (this is needed for e.g. loading files directly on startup).

The second one is needed for 32bit systems (sorry, I'm on x86_64 and didn't test this part) to execute the renamed pcbnew executable - not including this would cause an endless loop.

Sorry for this, I would love if one could edit comments on LP...

Nick Østergaard (nickoe) wrote :

I just built 4830 with the three python options ON and now scripting works for me. I have no crash on start and the wizarads works.

I did have problems building with more than -j1, something with:
src/kicad/common/../pcbnew/netlist_reader.h:39:80: fatal error: netlist_lexer.h: No such file or directory
that cmake apparently did not create. But that is probably for another bug report, so that I will not discuss further here.

Application: kicad
Version: (2014-04-25 BZR 4830)-kicad Release build
wxWidgets: Version 3.0.0 (debug,wchar_t,compiler with C++ ABI 1002,GCC 4.8.2,STL containers,compatible with 2.8)
Platform: Linux 3.14.1-1-ARCH x86_64, 64 bit, Little endian, wxGTK
Boost version: 1.55.0
         USE_WX_GRAPHICS_CONTEXT=OFF
         USE_WX_OVERLAY=OFF
         KICAD_SCRIPTING=ON
         KICAD_SCRIPTING_MODULES=ON
         KICAD_SCRIPTING_WXPYTHON=ON
         USE_FP_LIB_TABLE=HARD_CODED_ON
         BUILD_GITHUB_PLUGIN=ON

Nick Østergaard (nickoe) wrote :

Ok, when I start i.e. pcbnew or eeschema direftly it do not crash, but when I start them from the kicad thing, then it segfaults.

Thav (thavilden) wrote :

This is fixed for me in PPA version 0.201404290133+4837~13~ubuntu12.10.1, both in running from command line and from KiCad.

Changed in kicad:
status: New → Fix Committed
Jon Neal (reportingsjr) on 2015-09-26
Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Related questions