pcbnew crash when non-ActionPlugin-derived script is present

Bug #1820814 reported by Grzegorz Obuch on 2019-03-19
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

I've save attached script to C:\Program Files\KiCad\share\kicad\scripting\
Import this script in console in running pcbnew ends without any problem, but script left in this location cause crash when starting pcbnew or modedit every next time I try to open any project.

Application: kicad
Version: (5.1.0)-1, release build
    wxWidgets 3.0.4
    libcurl/7.61.1 OpenSSL/1.1.1 (WinSSL) zlib/1.2.11 brotli/1.0.6 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) nghttp2/1.34.0
Platform: Windows 8 (build 9200), 64-bit edition, 64 bit, Little endian, wxMSW
Build Info:
    wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8)
    Boost: 1.68.0
    OpenCASCADE Community Edition: 6.9.1
    Curl: 7.61.1
    Compiler: GCC 8.2.0 with C++ ABI 1013

Build settings:

Grzegorz Obuch (grzegorzobuch) wrote :
Seth Hillbrand (sethh) wrote :

Tried this in the equivalent linux location but no issues. Any windows devs can test this?

It crashes on my W7 32 bits install.
Because the script crashes (segfault) when running from a msys shell, i am guessing this script is run by the action script loader and the line:
"board = GetBoard()"
is executed before initializations are made, thus creating a segfault.

Of course, only action plugin scripts should be stored inside C:\Program Files\KiCad\share\kicad\scripting\

Wayne Stambaugh (stambaughw) wrote :

AFAIR, all scripts in the action plugin script paths must be derived from the ActionPlugin object. All other user python scripts should be placed a path not searched by the action plugin manager. The documentation for this can be found at http://docs.kicad-pcb.org/doxygen/md_Documentation_development_pcbnew-plugins.html. FYI, this documentation was not complete due to a markdown syntax bug. The bug has been fixed and the documentation will be updated as soon as the build server is done.

Jeff Young (jeyjey) wrote :

So is this a "won't fix" then?

Seth Hillbrand (sethh) wrote :

I think we should be able to determine whether scripts in the scripting directory are correct ActionPlugin derivatives without crashing.

Possible action would be to load the plugin as a string that is encapsulated rather loading a direct file. That would catch some issues but probably not all. But should catch this one

Nick Østergaard (nickoe) wrote :

It woyld be really nice to have kicad not crash when running a python script which is buggy, but I have no idea how that would work out.

tags: added: python
Changed in kicad:
importance: Undecided → High
status: New → Triaged
Jeff Young (jeyjey) on 2019-04-12
summary: - pcbnew crash
+ pcbnew crash when non-ActionPlugin-derived script is present
Andrew Lutsenko (qu1ck) wrote :

I think trying to determine if a script is action plugin or not is moot point. It may be an action plugin but it can still do some calls in init that are crashing pcbnew. Problem is the API calls that are crashing the program if it's not in correct state.

In this instance GetBoard() should do a sane thing and return None if pcbnew is not initialized yet.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Bug attachments