pcbnew: Segfault in DIALOG_GROUP_PROPERTIES destructor after pcbnew somehow lost track of tracks
Description
I tried to close pcbnew. Instead of closing, it segfaulted. It probably already was in some funny state; I had imported a Specctra session, and it showed more tracks than it should have. It took a long time to close (minutes, but that's probably largely because I run an unoptimized debug version inside GDB; still, that is a very long time), and then segfaulted. That funny state may be related to this crash.
Generally I use Global deletions -> Delete tracks and vias, and import Specctra session. It seems sometimes pcbnew ends up in a state where it draws tracks, but has somehow lost track of them otherwise, in that they cannot be selected and running global deletions on them does not affect them. Specctra import or global deletions may be involved. Sorry for the complex speculation and possible amalgamation of issues. I hope the backtrace brings some clarity or ideas.
Here's a GDB backtrace:
Thread 1 "kicad" received signal SIGSEGV, Segmentation fault.
0x00007fff716b659e in DIALOG_GROUP_PROPERTIES::~DIALOG_GROUP_PROPERTIES (this=0x55555dd19ab0, __in_chrg=<optimized out>) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/dialogs/dialog_group_properties.cpp:62
62 m_brdEditor->GetCanvas()->Refresh();
(gdb) bt
#0 0x00007fff716b659e in DIALOG_GROUP_PROPERTIES::~DIALOG_GROUP_PROPERTIES() (this=0x55555dd19ab0, __in_chrg=<optimized out>) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/dialogs/dialog_group_properties.cpp:62
#1 0x00007fff716b65d8 in DIALOG_GROUP_PROPERTIES::~DIALOG_GROUP_PROPERTIES() (this=0x55555dd19ab0, __in_chrg=<optimized out>) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/dialogs/dialog_group_properties.cpp:63
#2 0x00007ffff7a05e29 in wxWindowBase::Destroy() () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#3 0x00007ffff7a05e5d in wxWindowBase::DestroyChildren() () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#4 0x00007ffff7845498 in wxWindow::~wxWindow() () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#5 0x00007fff72376c01 in EDA_BASE_FRAME::~EDA_BASE_FRAME() (this=0x55555bd7aa90, __in_chrg=<optimized out>) at /home/sliedes/scratch/build/kicad/kicad/common/eda_base_frame.cpp:223
#6 0x00007fff723d7d2e in KIWAY_PLAYER::~KIWAY_PLAYER() (this=0x55555bd7aa90, __in_chrg=<optimized out>) at /home/sliedes/scratch/build/kicad/kicad/common/kiway_player.cpp:67
#7 0x00007fff72398b97 in EDA_DRAW_FRAME::~EDA_DRAW_FRAME() (this=0x55555bd7aa90, __in_chrg=<optimized out>) at /home/sliedes/scratch/build/kicad/kicad/common/eda_draw_frame.cpp:154
#8 0x00007fff71fda38b in PCB_BASE_FRAME::~PCB_BASE_FRAME() (this=0x55555bd7aa90, __in_chrg=<optimized out>) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/pcb_base_frame.cpp:76
#9 0x00007fff719dc2a2 in PCB_BASE_EDIT_FRAME::~PCB_BASE_EDIT_FRAME() (this=0x55555bd7aa90, __in_chrg=<optimized out>) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/pcb_base_edit_frame.cpp:56
#10 0x00007fff719e0e52 in PCB_EDIT_FRAME::~PCB_EDIT_FRAME() (this=0x55555bd7aa90, __in_chrg=<optimized out>) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/pcb_edit_frame.cpp:386
#11 0x00007fff719e0e8e in PCB_EDIT_FRAME::~PCB_EDIT_FRAME() (this=0x55555bd7aa90, __in_chrg=<optimized out>) at /home/sliedes/scratch/build/kicad/kicad/pcbnew/pcb_edit_frame.cpp:403
#12 0x00007ffff7349a85 in wxAppConsoleBase::DeletePendingObjects() () at /usr/lib/libwx_baseu-3.0.so.0
#13 0x00007ffff7349b08 in wxAppConsoleBase::ProcessIdle() () at /usr/lib/libwx_baseu-3.0.so.0
#14 0x00007ffff78e0425 in wxAppBase::ProcessIdle() () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#15 0x00007ffff780c596 in wxApp::DoIdle() () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#16 0x00007ffff780c6b4 in () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#17 0x00007ffff6126ea0 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#18 0x00007ffff617aa49 in () at /usr/lib/libglib-2.0.so.0
#19 0x00007ffff6126503 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0
#20 0x00007ffff69e458f in gtk_main () at /usr/lib/libgtk-3.so.0
#21 0x00007ffff7827b26 in wxGUIEventLoop::DoRun() () at /usr/lib/libwx_gtk3u_core-3.0.so.0
#22 0x00007ffff738537e in wxEventLoopBase::Run() () at /usr/lib/libwx_baseu-3.0.so.0
#23 0x00007ffff734b766 in wxAppConsoleBase::MainLoop() () at /usr/lib/libwx_baseu-3.0.so.0
#24 0x00005555556f824f in APP_KICAD::OnRun() (this=0x555555f810b0) at /home/sliedes/scratch/build/kicad/kicad/kicad/kicad.cpp:298
#25 0x00007ffff73ca199 in wxEntry(int&, wchar_t**) () at /usr/lib/libwx_baseu-3.0.so.0
#26 0x00005555556f6b45 in main(int, char**) (argc=2, argv=0x7fffffffd528) at /home/sliedes/scratch/build/kicad/kicad/kicad/kicad.cpp:344
KiCad Version
Application: KiCad PCB Editor
Version: (5.99.0-10041-g6eb2e2a6e3), debug build
Libraries:
wxWidgets 3.0.5
libcurl/7.75.0 OpenSSL/1.1.1k zlib/1.2.11 zstd/1.4.9 libidn2/2.3.0 libpsl/0.21.1 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.43.0
Platform: Linux 5.11.8-arch1-1 x86_64, 64 bit, Little endian, wxGTK, KDE, x11
Build Info:
Date: Mar 30 2021 18:05:35
wxWidgets: 3.0.5 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
Boost: 1.75.0
OCC: 7.5.0
Curl: 7.75.0
ngspice: 33
Compiler: GCC 10.2.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
KICAD_USE_OCC=ON
KICAD_SPICE=ON
KICAD_STDLIB_DEBUG=OFF
KICAD_STDLIB_LIGHT_DEBUG=OFF
KICAD_SANITIZE=OFF