Segfaults during library management

Hi all,

Before filing a bugreport, I thought I should discuss it here first.

Often, during library management, Kicad crashes hard and without advance warning.
Usually (but not always) this happens when I do the following:

Start KiCad, start the symbol editor and create a new symbol library.
Then I open an existing library, copy a symbol, and paste it into the newly created library.
Then I open the copied symbol in the symbol editor. I go to edit the properties to change the name of the symbol. When I click on save, it crashes:

valgrind kicad
==7966== Memcheck, a memory error detector
==7966== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==7966== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==7966== Command: kicad
==7966==
==7966== Conditional jump or move depends on uninitialised value(s)
==7966==    at 0x153D6070: ??? (in /usr/lib64/gtk-2.0/2.10.0/engines/libpixmap.so)
==7966==    by 0x153D6E3F: ??? (in /usr/lib64/gtk-2.0/2.10.0/engines/libpixmap.so)
==7966==    by 0x153D6EF1: ??? (in /usr/lib64/gtk-2.0/2.10.0/engines/libpixmap.so)
==7966==    by 0x153D3A7A: ??? (in /usr/lib64/gtk-2.0/2.10.0/engines/libpixmap.so)
==7966==    by 0x78CC958: ??? (in /usr/lib64/libgtk-x11-2.0.so.0.2400.32)
==7966==    by 0x7869ACA: ??? (in /usr/lib64/libgtk-x11-2.0.so.0.2400.32)
==7966==    by 0x8039B40: g_closure_invoke (in /usr/lib64/libgobject-2.0.so.0.6200.6)
==7966==    by 0x804D277: ??? (in /usr/lib64/libgobject-2.0.so.0.6200.6)
==7966==    by 0x805596E: g_signal_emit_valist (in /usr/lib64/libgobject-2.0.so.0.6200.6)
==7966==    by 0x805696E: g_signal_emit (in /usr/lib64/libgobject-2.0.so.0.6200.6)
==7966==    by 0x79790DB: ??? (in /usr/lib64/libgtk-x11-2.0.so.0.2400.32)
==7966==    by 0x77F375D: gtk_container_propagate_expose (in /usr/lib64/libgtk-x11-2.0.so.0.2400.32)
==7966==
==7966== Invalid read of size 8
==7966==    at 0x2D23F2C2: LIB_TREE_MODEL_ADAPTER::GetParent(wxDataViewItem const&) const (in /usr/bin/_eeschema.kiface)
==7966==    by 0x5223BD1: ??? (in /usr/lib64/libwx_gtk2u_adv-suse.so.3)
==7966==    by 0x52258A7: ??? (in /usr/lib64/libwx_gtk2u_adv-suse.so.3)
==7966==    by 0x52262F2: ??? (in /usr/lib64/libwx_gtk2u_adv-suse.so.3)
==7966==    by 0x794F745: ??? (in /usr/lib64/libgtk-x11-2.0.so.0.2400.32)
==7966==    by 0x794F79D: ??? (in /usr/lib64/libgtk-x11-2.0.so.0.2400.32)
==7966==    by 0x79541CF: ??? (in /usr/lib64/libgtk-x11-2.0.so.0.2400.32)
==7966==    by 0x795F253: gtk_tree_view_set_model (in /usr/lib64/libgtk-x11-2.0.so.0.2400.32)
==7966==    by 0x52227D9: ??? (in /usr/lib64/libwx_gtk2u_adv-suse.so.3)
==7966==    by 0x518E419: wxDataViewModel::BeforeReset() (in /usr/lib64/libwx_gtk2u_adv-suse.so.3)
==7966==    by 0x2D2406F6: LIB_TREE_MODEL_ADAPTER::UpdateSearchString(wxString const&) (in /usr/bin/_eeschema.kiface)
==7966==    by 0x2D1A5C9C: LIB_TREE::Regenerate(bool) (in /usr/bin/_eeschema.kiface)
==7966==  Address 0x5a35f6f8 is 8 bytes inside a block of size 368 free'd
==7966==    at 0x4C2FB6B: operator delete(void*) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==7966==    by 0x2D0C4B89: std::vector<std::unique_ptr<LIB_TREE_NODE, std::default_delete<LIB_TREE_NODE> >, std::allocator<std::unique_ptr
<LIB_TREE_NODE, std::default_delete<LIB_TREE_NODE> > > >::_M_erase(__gnu_cxx::__normal_iterator<std::unique_ptr<LIB_TREE_NODE, std::defaul
t_delete<LIB_TREE_NODE> >*, std::vector<std::unique_ptr<LIB_TREE_NODE, std::default_delete<LIB_TREE_NODE> >, std::allocator<std::unique_pt
r<LIB_TREE_NODE, std::default_delete<LIB_TREE_NODE> > > > >) (in /usr/bin/_eeschema.kiface)
==7966==    by 0x2D0C4108: SYMBOL_TREE_SYNCHRONIZING_ADAPTER::updateLibrary(LIB_TREE_NODE_LIB&) (in /usr/bin/_eeschema.kiface)
==7966==    by 0x2D0C433F: SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Sync(bool, std::function<void (int, int, wxString const&)>) (in /usr/bin/_ee
schema.kiface)
==7966==    by 0x2CF6A729: LIB_MANAGER::Sync(bool, std::function<void (int, int, wxString const&)>) (in /usr/bin/_eeschema.kiface)
==7966==    by 0x2CF44CF2: LIB_EDIT_FRAME::SyncLibraries(bool) (in /usr/bin/_eeschema.kiface)
==7966==    by 0x2CF70790: LIB_MANAGER::UpdatePartAfterRename(LIB_PART*, wxString const&, wxString const&) (in /usr/bin/_eeschema.kiface)
==7966==    by 0x2CF4937B: LIB_EDIT_FRAME::OnEditComponentProperties(wxCommandEvent&) (in /usr/bin/_eeschema.kiface)
==7966==    by 0x631A26D: wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) (in /usr/lib64/libw
x_baseu-suse.so.3)
==7966==    by 0x631AF42: wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) (in /usr/lib64/libwx_baseu-suse.so.3)
==7966==    by 0x631AFBA: wxEvtHandler::TryHereOnly(wxEvent&) (in /usr/lib64/libwx_baseu-suse.so.3)
==7966==    by 0x2D1FB851: EDA_BASE_FRAME::ProcessEvent(wxEvent&) (in /usr/bin/_eeschema.kiface)
==7966==  Block was alloc'd at
==7966==    at 0x4C2EAAF: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==7966==    by 0x2D23E077: LIB_TREE_NODE_LIB::AddItem(LIB_TREE_ITEM*) (in /usr/bin/_eeschema.kiface)
==7966==    by 0x2D0C407C: SYMBOL_TREE_SYNCHRONIZING_ADAPTER::updateLibrary(LIB_TREE_NODE_LIB&) (in /usr/bin/_eeschema.kiface)
==7966==    by 0x2D0C445F: SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Sync(bool, std::function<void (int, int, wxString const&)>) (in /usr/bin/_ee
schema.kiface)
==7966==    by 0x2CF6A729: LIB_MANAGER::Sync(bool, std::function<void (int, int, wxString const&)>) (in /usr/bin/_eeschema.kiface)
==7966==    by 0x2CF44B76: LIB_EDIT_FRAME::SyncLibraries(bool) (in /usr/bin/_eeschema.kiface)
==7966==    by 0x2CF4789E: LIB_EDIT_FRAME::LIB_EDIT_FRAME(KIWAY*, wxWindow*) (in /usr/bin/_eeschema.kiface)
==7966==    by 0x2CFB69CA: SCH::IFACE::CreateWindow(wxWindow*, int, KIWAY*, int) (in /usr/bin/_eeschema.kiface)
==7966==    by 0x20DF76: KIWAY::Player(FRAME_T, bool, wxTopLevelWindow*) (in /usr/bin/kicad)
==7966==    by 0x19B225: KICAD_MANAGER_FRAME::OnRunSchLibEditor(wxCommandEvent&) (in /usr/bin/kicad)
==7966==    by 0x631A26D: wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) (in /usr/lib64/libw
x_baseu-suse.so.3)
==7966==    by 0x631AF42: wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) (in /usr/lib64/libwx_baseu-suse.so.3)
==7966==

When I repeated the procedure using Valgrind it didn’t crash but it’s clear that there’s an illegal read which I believe is causing the crashes.
I installed the debug info and debug sourcecode files but I don’t know how to use them.
I have never debugged a program before that I didn’t compile myself from source.

Version info:

Application: KiCad
Version: 5.1.8-5.1.8, release build
Libraries:
wxWidgets 3.0.3
libcurl/7.66.0 OpenSSL/1.1.1d-fips zlib/1.2.11 libidn2/2.2.0 libpsl/0.20.1 (+libidn2/2.2.0) libssh/0.8.7/openssl/zlib nghttp2/1.40.0
Platform: Linux 5.3.18-lp152.57-default x86_64, 64 bit, Little endian, wxGTK
Build Info:
wxWidgets: 3.0.3 (wchar_t,STL containers,compatible with 2.8) GTK+ 2.24
Boost: 1.66.0
OpenCASCADE Technology: 7.3.0
Curl: 7.66.0
Compiler: GCC 7.5.0 with C++ ABI 1011

Build settings:
USE_WX_GRAPHICS_CONTEXT=OFF
USE_WX_OVERLAY=OFF
KICAD_SCRIPTING=ON
KICAD_SCRIPTING_MODULES=ON
KICAD_SCRIPTING_PYTHON3=OFF
KICAD_SCRIPTING_WXPYTHON=ON
KICAD_SCRIPTING_WXPYTHON_PHOENIX=OFF
KICAD_SCRIPTING_ACTION_MENU=ON
BUILD_GITHUB_PLUGIN=ON
KICAD_USE_OCE=OFF
KICAD_USE_OCC=ON
KICAD_SPICE=ON

Distro: OpenSuse Leap 15.2

Looks like the same issue raised here:


and

Will be fixed in 5.1.9

I have the same issue and had to rollback to 5.1.7 as creating/renaming on 5.1.8 (On Ubuntu) makes it impossible to work.

Those bugs are closed now, so the “testing” builds of 5.1 branch should work.

Thanks. I’d have to clone the repo and build from source correct? Unless there are 5.1.x nightly .deb files for Ubuntu that have escaped me?

The situation is a bit confusing. There’s https://launchpad.net/~js-reynaud/+archive/ubuntu/kicad-5-nightly which has a version from last night, the commit hash refers to a commit from yesterday, but the package version name is 5.1.5+. I can’t install KiCad from that ppa by standard means. Maybe the version number is interpreted as an old superseded version and apt refuses to install it by default?

EDIT: I could install it by downgrading, sudo apt-get install kicad=5.1.5+nightly-202012190103+d79aee3f78~88~ubuntu20.04.1 . It’s indeed the latest testing build:

Application: KiCad
Version: 5.1.8-unknown-nightly-202012190103, release build

Regardless of the package version number.

1 Like

Ok, no need to file a bugreport then.
To mitigate the problem, I copy and paste a symbol using a texteditor and modify it. After that I can use it in KiCad.
The fact that everything is stored in human readable ascii is a lifesaver.

Perfect. Thank you very much. It is a bit confusing with the versioning but I installed the latest 5.1.8 nightly and its fixed the issue.