eeschema crashes on changing default field names

Bug #1527309 reported by Chris Pavlina
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Medium
Unassigned

Bug Description

Preferences -> Schematic Editor Options -> Template Field Names

Edit the name of an existing field

Close dialog by pressing Alt+O (&OK hotkey)

Segfault. Works fine if you *click* OK.

Application: kicad
Version: (2015-12-16 BZR 6380, Git a3491a6)-product debug build
wxWidgets: Version 3.0.2 (debug,wchar_t,compiler with C++ ABI 1002,GCC 4.2.1,wx containers,compatible with 2.8)
Platform: Linux 4.2.5-1-ARCH x86_64, 64 bit, Little endian, wxGTK
Boost version: 1.59.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

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff36f9959 in _int_malloc () from /usr/lib/libc.so.6
(gdb) bt
#0 0x00007ffff36f9959 in _int_malloc () from /usr/lib/libc.so.6
#1 0x00007ffff36fb3d4 in malloc () from /usr/lib/libc.so.6
#2 0x00007ffff449b0e8 in operator new (sz=562949123453732) at /build/gcc-multilib/src/gcc-5.3.0/libstdc++-v3/libsupc++/new_op.cc:50
#3 0x00007ffff454078f in std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::_M_assign (this=0x7fffffffb658, __str=L"")
    at /build/gcc-multilib/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:269
#4 0x00007ffff6ca1de3 in wxGenericListCtrl::SetItem(long, int, wxString const&, int) () from /usr/lib/libwx_gtk2u_core-3.0.so.0
#5 0x00007fffe484b644 in DIALOG_EESCHEMA_OPTIONS::RefreshTemplateFieldView (this=0x7fffffffcaa8) at /home/cmp/git/kicad/eeschema/dialogs/dialog_eeschema_options.cpp:186
#6 0x00007fffe484ae99 in DIALOG_EESCHEMA_OPTIONS::OnEditControlKillFocus (this=0x7fffffffcaa8, event=...) at /home/cmp/git/kicad/eeschema/dialogs/dialog_eeschema_options.cpp:291
#7 0x00007ffff634c43e in wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const () from /usr/lib/libwx_baseu-3.0.so.0
#8 0x00007ffff64d2a77 in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from /usr/lib/libwx_baseu-3.0.so.0
#9 0x00007ffff64d2e5e in wxEvtHandler::SearchDynamicEventTable(wxEvent&) () from /usr/lib/libwx_baseu-3.0.so.0
#10 0x00007ffff64d2eee in wxEvtHandler::TryHereOnly(wxEvent&) () from /usr/lib/libwx_baseu-3.0.so.0
#11 0x00007ffff64d2fb3 in wxEvtHandler::ProcessEventLocally(wxEvent&) () from /usr/lib/libwx_baseu-3.0.so.0
#12 0x00007ffff64d3015 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib/libwx_baseu-3.0.so.0
#13 0x00007ffff64d2d77 in wxEvtHandler::SafelyProcessEvent(wxEvent&) () from /usr/lib/libwx_baseu-3.0.so.0
#14 0x00007ffff6d09941 in wxTextCtrl::GTKProcessEvent(wxEvent&) const () from /usr/lib/libwx_gtk2u_core-3.0.so.0
#15 0x00007ffff6c78682 in wxWindow::GTKHandleFocusOutNoDeferring() () from /usr/lib/libwx_gtk2u_core-3.0.so.0
#16 0x00007ffff6c78c00 in wxWindow::GTKHandleFocusOut() () from /usr/lib/libwx_gtk2u_core-3.0.so.0
#17 0x00007ffff6c7901c in ?? () from /usr/lib/libwx_gtk2u_core-3.0.so.0
#18 0x00007ffff316fbbc in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#19 0x00007ffff2b46015 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#20 0x00007ffff2b58304 in ?? () from /usr/lib/libgobject-2.0.so.0
#21 0x00007ffff2b60899 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#22 0x00007ffff2b6112f in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#23 0x00007ffff328752c in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#24 0x00007ffff3293571 in gtk_widget_send_focus_change () from /usr/lib/libgtk-x11-2.0.so.0
#25 0x00007ffff3293803 in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#26 0x00007ffff32939aa in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#27 0x00007ffff2b49117 in g_cclosure_marshal_VOID__OBJECTv () from /usr/lib/libgobject-2.0.so.0
#28 0x00007ffff2b46244 in ?? () from /usr/lib/libgobject-2.0.so.0
#29 0x00007ffff2b60a46 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#30 0x00007ffff2b6112f in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#31 0x00007ffff6c669d5 in wxTopLevelWindowGTK::~wxTopLevelWindowGTK() () from /usr/lib/libwx_gtk2u_core-3.0.so.0
#32 0x00007fffe4a4ab66 in DIALOG_SHIM::~DIALOG_SHIM (this=0x7fffffffcaa8) at /home/cmp/git/kicad/common/dialog_shim.cpp:98
#33 0x00007fffe4849355 in DIALOG_EESCHEMA_OPTIONS_BASE::~DIALOG_EESCHEMA_OPTIONS_BASE (this=0x7fffffffcaa8) at /home/cmp/git/kicad/eeschema/dialogs/dialog_eeschema_options_base.cpp:307
#34 0x00007fffe484cdca in DIALOG_EESCHEMA_OPTIONS::~DIALOG_EESCHEMA_OPTIONS (this=0x7fffffffcaa8) at /home/cmp/git/kicad/eeschema/./dialogs/dialog_eeschema_options.h:37
#35 0x00007fffe48a67fe in SCH_EDIT_FRAME::OnPreferencesOptions (this=0xa5bcc0, event=...) at /home/cmp/git/kicad/eeschema/eeschema_config.cpp:411
#36 0x00007ffff634c43e in wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const () from /usr/lib/libwx_baseu-3.0.so.0
#37 0x00007ffff64d2a77 in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () from /usr/lib/libwx_baseu-3.0.so.0
#38 0x00007ffff64d2b6b in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) () from /usr/lib/libwx_baseu-3.0.so.0
#39 0x00007ffff64d2f28 in wxEvtHandler::TryHereOnly(wxEvent&) () from /usr/lib/libwx_baseu-3.0.so.0
#40 0x00007fffe4a1f26d in EDA_BASE_FRAME::ProcessEvent (this=0xa5bcc0, aEvent=...) at /home/cmp/git/kicad/common/basicframe.cpp:167
#41 0x00007ffff64d2d23 in wxEvtHandler::DoTryChain(wxEvent&) () from /usr/lib/libwx_baseu-3.0.so.0
#42 0x00007ffff64d3015 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib/libwx_baseu-3.0.so.0
#43 0x00007ffff6e5bdc8 in wxWindowBase::TryAfter(wxEvent&) () from /usr/lib/libwx_gtk2u_core-3.0.so.0
#44 0x00007ffff64d2d77 in wxEvtHandler::SafelyProcessEvent(wxEvent&) () from /usr/lib/libwx_baseu-3.0.so.0
#45 0x00007ffff6e00c2f in wxMenuBase::SendEvent(int, int) () from /usr/lib/libwx_gtk2u_core-3.0.so.0
#46 0x00007ffff6ce394b in ?? () from /usr/lib/libwx_gtk2u_core-3.0.so.0
#47 0x00007ffff2b46015 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#48 0x00007ffff2b58061 in ?? () from /usr/lib/libgobject-2.0.so.0
#49 0x00007ffff2b60dfc in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#50 0x00007ffff2b6112f in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#51 0x00007ffff32862be in gtk_widget_activate () from /usr/lib/libgtk-x11-2.0.so.0
#52 0x00007ffff318194d in gtk_menu_shell_activate_item () from /usr/lib/libgtk-x11-2.0.so.0
#53 0x00007ffff3181cae in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#54 0x00007ffff316fbbc in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#55 0x00007ffff2b46015 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#56 0x00007ffff2b5860e in ?? () from /usr/lib/libgobject-2.0.so.0
#57 0x00007ffff2b60899 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#58 0x00007ffff2b6112f in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#59 0x00007ffff328752c in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#60 0x00007ffff316e354 in gtk_propagate_event () from /usr/lib/libgtk-x11-2.0.so.0
#61 0x00007ffff316e70b in gtk_main_do_event () from /usr/lib/libgtk-x11-2.0.so.0
#62 0x00007ffff2de348c in ?? () from /usr/lib/libgdk-x11-2.0.so.0
#63 0x00007ffff1e26dc7 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#64 0x00007ffff1e27020 in ?? () from /usr/lib/libglib-2.0.so.0
#65 0x00007ffff1e27342 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
#66 0x00007ffff316d787 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#67 0x00007ffff6c46165 in wxGUIEventLoop::DoRun() () from /usr/lib/libwx_gtk2u_core-3.0.so.0
#68 0x00007ffff638e223 in wxEventLoopBase::Run() () from /usr/lib/libwx_baseu-3.0.so.0
#69 0x00007ffff6353306 in wxAppConsoleBase::MainLoop() () from /usr/lib/libwx_baseu-3.0.so.0
#70 0x0000000000443604 in APP_KICAD::OnRun (this=0x7e47e0) at /home/cmp/git/kicad/kicad/kicad.cpp:288
---Type <return> to continue, or q <return> to quit---
#71 0x00007ffff63e01e0 in wxEntry(int&, wchar_t**) () from /usr/lib/libwx_baseu-3.0.so.0
#72 0x0000000000441836 in main (argc=1, argv=0x7fffffffe6c8) at /home/cmp/git/kicad/kicad/kicad.cpp:320
(gdb)

Revision history for this message
Chris Pavlina (pavlina-chris) wrote :

Side note: pressing Enter doesn't "OK" the dialog, because somebody decided that should switch between the Name and Value fields instead, and wrote special code to achieve this. Why??! That's what Tab is for. Can we please rip that out?

Revision history for this message
Wayne Stambaugh (stambaughw) wrote : Re: [Bug 1527309] Re: eeschema crashes on changing default field names

If it resolves the issue and doesn't create any new ones, I'm OK with
removing it.

On 12/17/2015 10:55 AM, Chris Pavlina wrote:
> Side note: pressing Enter doesn't "OK" the dialog, because somebody
> decided that should switch between the Name and Value fields instead,
> and wrote special code to achieve this. Why??! That's what Tab is for.
> Can we please rip that out?
>

Revision history for this message
Chris Pavlina (pavlina-chris) wrote :

It's not going to resolve the issue, it's just a weird UI quirk that I'd like to be rid of (which I discovered at the same time).

The crash itself is happening in a really weird place, I suspect memory issues at some point. No time to investigate right now, but I'll look into it soon.

Revision history for this message
Chris Pavlina (pavlina-chris) wrote :
Download full text (3.8 KiB)

Somehow, DIALOG_EESCHEMA_OPTIONS::OnEditControlKillFocus(wxFocusEvent&) is being called after DIALOG_EESCHEMA_OPTIONS::~DIALOG_EESCHEMA_OPTIONS()...

==25924== Invalid read of size 8
==25924== at 0x8827714: _M_data (basic_string.h:135)
==25924== by 0x8827714: _M_is_local (basic_string.h:170)
==25924== by 0x8827714: capacity (basic_string.h:781)
==25924== by 0x8827714: std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::_M_assign(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&) (basic_string.tcc:264)
==25924== by 0x8827A88: assign (basic_string.h:1096)
==25924== by 0x8827A88: std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::operator=(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&) (basic_string.h:552)
==25924== by 0x1BCF7AFE: wxString::operator=(wxString const&) (string.h:1883)
==25924== by 0x1BDB8699: DIALOG_EESCHEMA_OPTIONS::copyPanelToSelected() (dialog_eeschema_options.cpp:281)
==25924== by 0x1BDB769F: DIALOG_EESCHEMA_OPTIONS::OnEditControlKillFocus(wxFocusEvent&) (dialog_eeschema_options.cpp:290)
==25924== by 0x64FA43D: wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const (in /usr/lib/libwx_baseu-3.0.so.0.2.0)
==25924== by 0x6680A76: wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) (in /usr/lib/libwx_baseu-3.0.so.0.2.0)
==25924== by 0x6680E5D: wxEvtHandler::SearchDynamicEventTable(wxEvent&) (in /usr/lib/libwx_baseu-3.0.so.0.2.0)
==25924== by 0x6680EED: wxEvtHandler::TryHereOnly(wxEvent&) (in /usr/lib/libwx_baseu-3.0.so.0.2.0)
==25924== by 0x6680FB2: wxEvtHandler::ProcessEventLocally(wxEvent&) (in /usr/lib/libwx_baseu-3.0.so.0.2.0)
==25924== by 0x6681014: wxEvtHandler::ProcessEvent(wxEvent&) (in /usr/lib/libwx_baseu-3.0.so.0.2.0)
==25924== by 0x6680D76: wxEvtHandler::SafelyProcessEvent(wxEvent&) (in /usr/lib/libwx_baseu-3.0.so.0.2.0)
==25924== Address 0x18707480 is 208 bytes inside a block of size 312 free'd
==25924== at 0x4C2A144: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==25924== by 0x1BDB9A0F: __gnu_cxx::new_allocator<TEMPLATE_FIELDNAME>::deallocate(TEMPLATE_FIELDNAME*, unsigned long) (in /opt/kicad-master/bin/_eeschema.kiface)
==25924== by 0x1BDB99DF: __gnu_cxx::__alloc_traits<std::allocator<TEMPLATE_FIELDNAME> >::deallocate(std::allocator<TEMPLATE_FIELDNAME>&, TEMPLATE_FIELDNAME*, unsigned long) (in /opt/kicad-master/bin/_eeschema.kiface)
==25924== by 0x1BDB997A: std::_Vector_base<TEMPLATE_FIELDNAME, std::allocator<TEMPLATE_FIELDNAME> >::_M_deallocate(TEMPLATE_FIELDNAME*, unsigned long) (stl_vector.h:178)
==25924== by 0x1BDB9846: std::_Vector_base<TEMPLATE_FIELDNAME, std::allocator<TEMPLATE_FIELDNAME> >::~_Vector_base() (stl_vector.h:160)
==25924== by 0x1BDB8CB1: std::vector<TEMPLATE_FIELDNAME, std::allocator<TEMPLATE_FIELDNAME> >::~vector() (in /opt/kicad-master/bin/_eeschema.kiface)
==25924== by 0x1BDB95C8: DIALOG_EESCHEMA_OPTIONS::~DIALOG_EESCHEMA_OPTIONS() (in /opt/kicad-master...

Read more...

Revision history for this message
Chris Pavlina (pavlina-chris) wrote :

This thread hints at the cause of the problem, and a possible solution: https://forums.wxwidgets.org/viewtopic.php?t=16887

However, the solution doesn't quite work - it solves the segfault,but changes the behavior.

Ideally, since I'm working on cleaning up the preferences anyway, I'd like to ditch this approach entirely and make the listview directly editable. Thoughts or objections?

Changed in kicad:
status: New → In Progress
Changed in kicad:
status: In Progress → Fix Committed
Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.