pcbnew: Crash in connectivity_algo.cpp when adding, then removing traces from script
Description
When I add a bunch of traces from a python script (happens both when run from a plugin and when run from the console), pcbnew crashes in connectivity_algo.cpp. This is potentially related to #2071 (closed) since the added traces do not get drawn properly.
Steps to reproduce
- Run pcbnew in stand-alone (haven't tried project mode yet).
- Run the following python code either through the console or through an action plugin:
import pcbnew
board = pcbnew.GetBoard()
def run_test():
from shapely import geometry
target_layer_id = board.GetLayerID('F.Cu')
def add_track(segment:geometry.LineString):
coords = list(segment.coords)
for (x1, y1), (x2, y2) in zip(coords, coords[1:]):
track = pcbnew.TRACK(board)
track.SetStatus(track.GetStatus() | pcbnew.TRACK_AR)
track.SetStart(pcbnew.wxPoint(pcbnew.FromMM(x1), pcbnew.FromMM(y1)))
track.SetEnd(pcbnew.wxPoint(pcbnew.FromMM(x2), pcbnew.FromMM(y2)))
track.SetWidth(pcbnew.FromMM(0.127))
track.SetLayer(target_layer_id)
board.Add(track)
for i in range(5000):
add_track(geometry.LineString([(i/10, 0), (i/10, 1), ((i+1)/10, 1), ((i+1/10), 0)]))
for track in board.GetTracks():
if track.GetStatus() & pcbnew.TRACK_AR:
board.Remove(track)
KiCad Version
Version info (5.99.0-2743-g9cdada9e)
Application: Pcbnew Version: (5.99.0-2743-g9cdada9eb), release build Libraries: wxWidgets 3.0.5 libcurl/7.71.1 OpenSSL/1.1.1g zlib/1.2.11 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh2/1.9.0 nghttp2/1.41.0 Platform: Linux 4.4.0-18362-Microsoft x86_64, 64 bit, Little endian, wxGTK Build Info: Date: Aug 14 2020 15:31:14 wxWidgets: 3.0.5 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24 Boost: 1.72.0 OCC: 7.4.0 Curl: 7.71.1 ngspice: 32 Compiler: GCC 10.1.0 with C++ ABI 1014 Build settings: KICAD_SCRIPTING=ON KICAD_SCRIPTING_MODULES=ON KICAD_SCRIPTING_PYTHON3=ON KICAD_SCRIPTING_WXPYTHON=ON KICAD_SCRIPTING_WXPYTHON_PHOENIX=ON KICAD_SCRIPTING_ACTION_MENU=ON BUILD_GITHUB_PLUGIN=ON KICAD_USE_OCC=ON KICAD_SPICE=ON
Backtrace
gdb backtrace
Thread 1 "pcbnew" received signal SIGSEGV, Segmentation fault. 0x0000000000000001 in ?? () (gdb) bt #0 0x0000000000000001 in () #1 0x00007ffffa53273a in CN_CONNECTIVITY_ALGO::markItemNetAsDirty(BOARD_ITEM const*) (this=0xad965c0, aItem=0xac81ae0) at /home/user/kicad/pcbnew/connectivity/connectivity_algo.cpp:96 #2 0x00007ffffa53280b in CN_CONNECTIVITY_ALGO::Remove(BOARD_ITEM*) (this=0xad965c0, aItem=, aItem@entry=0xac81ae0) at /home/user/kicad/pcbnew/connectivity/connectivity_algo.cpp:42 #3 0x00007ffffa51e42c in CONNECTIVITY_DATA::Remove(BOARD_ITEM*) (this=, aItem=aItem@entry=0xac81ae0) at /usr/include/c++/10.1.0/bits/shared_ptr_base.h:1324 #4 0x00007ffffa573500 in BOARD::Remove(BOARD_ITEM*) (this=0xad8b320, aBoardItem=0xac81ae0) at /usr/include/c++/10.1.0/bits/shared_ptr_base.h:1324 #5 0x00007ffffa282058 in _wrap_BOARD_RemoveNative(PyObject*, PyObject*) (args=) at /home/user/kicad/pcbnew/pcbnew_wrap.cxx:151322 #6 0x00007ffff970540a in PyCFunction_Call () at /usr/lib/libpython3.8.so.1.0 #7 0x00007ffff96f7d84 in _PyObject_MakeTpCall () at /usr/lib/libpython3.8.so.1.0 #8 0x00007ffff96f3668 in _PyEval_EvalFrameDefault () at /usr/lib/libpython3.8.so.1.0 #9 0x00007ffff96ff348 in _PyFunction_Vectorcall () at /usr/lib/libpython3.8.so.1.0 #10 0x00007ffff96eecd1 in _PyEval_EvalFrameDefault () at /usr/lib/libpython3.8.so.1.0 #11 0x00007ffff96ff348 in _PyFunction_Vectorcall () at /usr/lib/libpython3.8.so.1.0 #12 0x00007ffff96eecd1 in _PyEval_EvalFrameDefault () at /usr/lib/libpython3.8.so.1.0 #13 0x00007ffff96ed972 in _PyEval_EvalCodeWithName () at /usr/lib/libpython3.8.so.1.0 #14 0x00007ffff96ff3dd in _PyFunction_Vectorcall () at /usr/lib/libpython3.8.so.1.0 #15 0x00007ffff96ee90c in _PyEval_EvalFrameDefault () at /usr/lib/libpython3.8.so.1.0 #16 0x00007ffff96ed254 in _PyEval_EvalCodeWithName () at /usr/lib/libpython3.8.so.1.0 #17 0x00007ffff979e083 in PyEval_EvalCode () at /usr/lib/libpython3.8.so.1.0 #18 0x00007ffff97a343d in () at /usr/lib/libpython3.8.so.1.0 #19 0x00007ffff96ffbf8 in () at /usr/lib/libpython3.8.so.1.0 #20 0x00007ffff96ee90c in _PyEval_EvalFrameDefault () at /usr/lib/libpython3.8.so.1.0 #21 0x00007ffff96ff348 in _PyFunction_Vectorcall () at /usr/lib/libpython3.8.so.1.0 #22 0x00007ffff96eecd1 in _PyEval_EvalFrameDefault () at /usr/lib/libpython3.8.so.1.0 #23 0x00007ffff96ed254 in _PyEval_EvalCodeWithName () at /usr/lib/libpython3.8.so.1.0 #24 0x00007ffff96ff3dd in _PyFunction_Vectorcall () at /usr/lib/libpython3.8.so.1.0 #25 0x00007ffff96f3225 in _PyEval_EvalFrameDefault () at /usr/lib/libpython3.8.so.1.0 #26 0x00007ffff96ff348 in _PyFunction_Vectorcall () at /usr/lib/libpython3.8.so.1.0 #27 0x00007ffff96eecd1 in _PyEval_EvalFrameDefault () at /usr/lib/libpython3.8.so.1.0 #28 0x00007ffff96ed254 in _PyEval_EvalCodeWithName () at /usr/lib/libpython3.8.so.1.0 #29 0x00007ffff96ff3dd in _PyFunction_Vectorcall () at /usr/lib/libpython3.8.so.1.0 #30 0x00007ffff96eecd1 in _PyEval_EvalFrameDefault () at /usr/lib/libpython3.8.so.1.0 #31 0x00007ffff96ed254 in _PyEval_EvalCodeWithName () at /usr/lib/libpython3.8.so.1.0 #32 0x00007ffff96ff3dd in _PyFunction_Vectorcall () at /usr/lib/libpython3.8.so.1.0 #33 0x00007ffff96eecd1 in _PyEval_EvalFrameDefault () at /usr/lib/libpython3.8.so.1.0 #34 0x00007ffff96ff348 in _PyFunction_Vectorcall () at /usr/lib/libpython3.8.so.1.0 #35 0x00007ffff96eecd1 in _PyEval_EvalFrameDefault () at /usr/lib/libpython3.8.so.1.0 #36 0x00007ffff96ff348 in _PyFunction_Vectorcall () at /usr/lib/libpython3.8.so.1.0 #37 0x00007ffff970ed3c in () at /usr/lib/libpython3.8.so.1.0 #38 0x00007ffff97124c2 in PyObject_Call () at /usr/lib/libpython3.8.so.1.0 #39 0x00007ffff6f79137 in wxPyCallback::EventThunker(wxEvent&) () at /usr/lib/python3.8/site-packages/wx/_core.cpython-38-x86_64-linux-gnu.so #40 0x00007ffffec7a4c1 in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0 #41 0x00007ffffec7a84b in wxEvtHandler::SearchDynamicEventTable(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0 #42 0x00007ffffec7a8e1 in wxEvtHandler::TryHereOnly(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0 #43 0x00007ffffec7a994 in wxEvtHandler::ProcessEventLocally(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0 #44 0x00007ffffec7aa32 in wxEvtHandler::ProcessEvent(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0 #45 0x00007ffff8f06a9c in sipwxStyledTextCtrl::ProcessEvent(wxEvent&) () at /usr/lib/python3.8/site-packages/wx/_stc.cpython-38-x86_64-linux-gnu.so #46 0x00007ffffec7a7c7 in wxEvtHandler::SafelyProcessEvent(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0 #47 0x00007fffff0406a4 in () at /usr/lib/libwx_gtk3u_core-3.0.so.0 #48 0x00007ffffd2f2f6f in () at /usr/lib/libgtk-3.so.0 #49 0x00007ffffd113052 in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0 #50 0x00007ffffd13b685 in () at /usr/lib/libgobject-2.0.so.0 #51 0x00007ffffd12ea4b in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0 #52 0x00007ffffd12f980 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0 #53 0x00007ffffd5b84a5 in () at /usr/lib/libgtk-3.so.0 #54 0x00007ffffd5c70dc in gtk_window_propagate_key_event () at /usr/lib/libgtk-3.so.0 #55 0x00007fffff02a0ec in () at /usr/lib/libwx_gtk3u_core-3.0.so.0 #56 0x00007ffffd2f2f6f in () at /usr/lib/libgtk-3.so.0 #57 0x00007ffffd113052 in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0 #58 0x00007ffffd13b685 in () at /usr/lib/libgobject-2.0.so.0 #59 0x00007ffffd12ea4b in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0 #60 0x00007ffffd12f980 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0 #61 0x00007ffffd5b84a5 in () at /usr/lib/libgtk-3.so.0 #62 0x00007ffffd451d22 in () at /usr/lib/libgtk-3.so.0 #63 0x00007ffffd452fad in gtk_main_do_event () at /usr/lib/libgtk-3.so.0 #64 0x00007ffffd19c793 in () at /usr/lib/libgdk-3.so.0 #65 0x00007ffffd1ecf94 in () at /usr/lib/libgdk-3.so.0 #66 0x00007ffffce5243c in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0 #67 0x00007ffffcea01d9 in () at /usr/lib/libglib-2.0.so.0 #68 0x00007ffffce50c03 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0 #69 0x00007ffffd45008f in gtk_main () at /usr/lib/libgtk-3.so.0 #70 0x00007fffff017856 in wxGUIEventLoop::DoRun() () at /usr/lib/libwx_gtk3u_core-3.0.so.0 #71 0x00007ffffeb30e0e in wxEventLoopBase::Run() () at /usr/lib/libwx_baseu-3.0.so.0 #72 0x00007ffffeaf5f27 in wxAppConsoleBase::MainLoop() () at /usr/lib/libwx_baseu-3.0.so.0 #73 0x00000000080438c9 in APP_SINGLE_TOP::OnRun() (this=) at /home/user/kicad/common/single_top.cpp:209 #74 0x00007ffffeb847f9 in wxEntry(int&, wchar_t**) () at /usr/lib/libwx_baseu-3.0.so.0 #75 0x000000000803df98 in main(int, char**) (argc=, argv=) at /home/user/kicad/common/single_top.cpp:283
Edited by jaseg