← Back to team overview

kicad-developers team mailing list archive

Re: Crash invoking pcbnew Board settings

 

He he… yeah, this is one of the reasons our coding style discourages the use of “auto” — it tends to obfuscate the code.  However, a lot of C++ programmers are used to using it, so it tends to creep in from time to time.

The case given should read:

    for( const std::pair<const wxString, std::shared_ptr<NETCLASS>>& netclass : netclasses )
    {
        m_netclassGrid->SetCellValue( row, GRID_NAME, netclass.first );

so netclass.first is the key to the netclass in the netclasses map (ie: the netclass name).

However, if you’re seeing the crash when opening the Board Settings dialog, then I don’t think this is the issue (that’s a completely separate dialog).  Sadly the flatpak doesn’t contain symbols so it’s a little hard to match the backtrace up with the code.

Can you send us a copy of the project (with the -1 re-instated so that it crashes) so we can see if we can reproduce it?  (Even if it’s from a bad file, it’d still be nice to not crash on it.)

Cheers,
Jeff.


> On 6 Nov 2021, at 01:59, Ruth Ivimey-Cook <ruth@xxxxxxxxxx> wrote:
> 
> Hi
> 
> I've been using the nightly build of kicad via flatpak (because of the WxWidgets issues on Linux) for a while, and have encountered a fairly consistent crash when invoking board settings from the File menu of pcbnew.
> 
> The build is from this evening, using up to date flatpak and libs, was done on ubuntu 21.04. However I have also experienced a very similar crash with the same project using a recent (~week old) MacOS build.
> 
> The crash results in this appearing in the terminal window:
> 
>> terminate called after throwing an instance of 'std::bad_alloc'
>>   what():  std::bad_alloc
> [aside: could Kicad catch such exceptions rather than having the window just disappear?]
> 
> Invoking gdb produces a backtrace of 54 frames of which the top 27 are somewhat interesting:
> 
>> (gdb) bt
>> #0  0x00007ffff5a6d4bb in raise () at /usr/lib/x86_64-linux-gnu/libc.so.6
>> #1  0x00007ffff5a56867 in abort () at /usr/lib/x86_64-linux-gnu/libc.so.6
>> #2  0x00007ffff5e308f9 in __gnu_cxx::__verbose_terminate_handler() [clone .cold] () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
>> #3  0x00007ffff5e3c62a in __cxxabiv1::__terminate(void (*)()) () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
>> #4  0x00007ffff5e3c695 in  () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
>> #5  0x00007ffff5e3c971 in  () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
>> #6  0x00007ffff5e3050e in operator new(unsigned long, std::nothrow_t const&) [clone .cold] () at /usr/lib/x86_64-linux-gnu/libstdc++.so.6
>> #7  0x0000555555858695 in 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&) ()
>> #8  0x00007ffff7be21e2 in wxGrid::SetCellValue(int, int, wxString const&) () at /app/lib/libwx_gtk3u_core-3.1.so.5
>> #9  0x00007fffcaefe280 in  () at /app/bin/_pcbnew.kiface
>> #10 0x00007fffcaf034f3 in  () at /app/bin/_pcbnew.kiface
>> #11 0x00007ffff7b21728 in wxWindowBase::TransferDataToWindow() () at /app/lib/libwx_gtk3u_core-3.1.so.5
>> #12 0x00007ffff7b21728 in wxWindowBase::TransferDataToWindow() () at /app/lib/libwx_gtk3u_core-3.1.so.5
>> #13 0x00007fffcaf40227 in  () at /app/bin/_pcbnew.kiface
>> #14 0x00007ffff7b21b32 in wxWindowBase::OnInitDialog(wxInitDialogEvent&) () at /app/lib/libwx_gtk3u_core-3.1.so.5
>> #15 0x00007ffff746229e in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) ()
>>     at /app/lib/libwx_baseu-3.1.so.5
>> #16 0x00007ffff7462443 in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) () at /app/lib/libwx_baseu-3.1.so.5
>> #17 0x00007ffff7462b56 in wxEvtHandler::TryHereOnly(wxEvent&) () at /app/lib/libwx_baseu-3.1.so.5
>> #18 0x00007ffff7462be0 in wxEvtHandler::ProcessEventLocally(wxEvent&) () at /app/lib/libwx_baseu-3.1.so.5
>> #19 0x00007ffff7462cf2 in wxEvtHandler::ProcessEvent(wxEvent&) () at /app/lib/libwx_baseu-3.1.so.5
>> #20 0x00007ffff7b1a2ce in wxWindowBase::InitDialog() () at /app/lib/libwx_gtk3u_core-3.1.so.5
>> #21 0x00007ffff7972114 in wxDialog::Show(bool) () at /app/lib/libwx_gtk3u_core-3.1.so.5
>> #22 0x00007fffcafc7e7a in  () at /app/bin/_pcbnew.kiface
>> #23 0x00007fffcafc68a6 in  () at /app/bin/_pcbnew.kiface
>> #24 0x00007fffca7a74ad in  () at /app/bin/_pcbnew.kiface
>> #25 0x00007fffca823117 in  () at /app/bin/_pcbnew.kiface
>> #26 0x00007fffcb0fd3a0 in  () at /app/bin/_pcbnew.kiface
>> #27 0x00007fffcb19e211 in make_fcontext () at /app/bin/_pcbnew.kiface
>> #28 0x0000007800000031 in  ()
> 
> Suggestions online are that the crash is to do with using a the address of a local variable out of scope. Having looked at the code, and using SetCellValue as the anchor point, I believe the problem lies in the code in:
> 
>> dialog_global_edit_tracks_and_vias.cpp: void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildNetclassesGrid()
> 
> and specifically in the netclass loop:
> 
>>     for( const auto& netclass : netclasses )
>>     {
>>         m_netclassGrid->SetCellValue( row, GRID_NAME, netclass.first );
> 
> I'm not quite following where 'first' is defined in 'auto& netclass', however, so cannot pinpoint the actual problem.
> 
> Hope this is enough to be useful.
> 
> Ruth
> 
> 
> -- 
> Tel: 01223 414180
> Blog: http://www.ivimey.org/blog
> LinkedIn: http://uk.linkedin.com/in/ruthivimeycook/
> 
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp



References