← Back to team overview

kicad-developers team mailing list archive

Re: How to track down an exception?

 

On Thu, Sep 11, 2014 at 08:23:04PM +0200, jp charras wrote:
> Do you have this bug with any board?  with any footprint on board ? with
> any footprint lib?  with any footprint lib type (legacy, Kicad, Github)?

I found the error sporadically on a couple board I'm working on, usually
when importing the netlist with the 'change module' option. AFAIK that's
more or less the code path used by the change module dialog. I only use
the new pretty libraries and only today I found a way to reproduce the
issue (on a library master board). It also occurs when I load another
board and then do a change on the module I edited before.

It's *quite* reliable in reproduction, it seems to work with many
footprints with no preference...

I'm trying to catch it with valgrind but with a 257M executable and
valgrind speed is not exactly a quick thing! I got two interesting stack
traces until now:

This probably would have been a segfault (but valgrind 'cleans'
freed/unused memory so it took another way):

==6918== Invalid read of size 4
==6918==    at 0xE797887: RN_DATA::Add(BOARD_ITEM const*) (class_board_connected_item.h:100)
==6918==    by 0xE75055E: BOARD::Add(BOARD_ITEM*, int) (class_board.cpp:716)
==6918==    by 0xE6CC695: DIALOG_EXCHANGE_MODULE::Change_1_Module(MODULE*, FPID const&, PICKED_ITEMS_LIST*, bool) (xchgmod.cpp:411)
==6918==    by 0xE6CCDAB: DIALOG_EXCHANGE_MODULE::ChangeCurrentFootprint() (xchgmod.cpp:212)
==6918==    by 0x570A63D: wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const (appbase.cpp:623)
==6918==    by 0x585D3D1: wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) (event.cpp:1384)
==6918==    by 0x585D735: wxEvtHandler::SearchDynamicEventTable(wxEvent&) (event.cpp:1743)
==6918==    by 0x585D7BD: wxEvtHandler::TryHereOnly(wxEvent&) (event.cpp:1577)
==6918==    by 0x585D852: wxEvtHandler::ProcessEventLocally(wxEvent&) (event.h:3671)
==6918==    by 0x585D8B4: wxEvtHandler::ProcessEvent(wxEvent&) (event.cpp:1487)
==6918==    by 0x585D646: wxEvtHandler::SafelyProcessEvent(wxEvent&) (event.cpp:1605)
==6918==    by 0x590A8F8: wxgtk_button_clicked_callback (button.cpp:40)
==6918==  Address 0x112c2330 is not stack'd, malloc'd or (recently) free'd
==6918== 

That one instead is the bad_alloc equivalent:

**6460** new/new[] failed and should throw an exception, but Valgrind
**6460**    cannot throw exceptions and so is aborting instead.  Sorry.
==6460==    at 0x4C2718C: VALGRIND_PRINTF_BACKTRACE (valgrind.h:5111)
==6460==    by 0x4C279C0: operator new(unsigned long) (vg_replace_malloc.c:319)
==6460==    by 0xE7A3FE5: std::vector<RN_NET, std::allocator<RN_NET> >::_M_fill_insert(__gnu_cxx::__normal_iterator<RN_NET*, std::vector<RN_NET, std::allocator<RN_NET> > >, unsigned long, RN_NET const&) (new_allocator.h:104)
==6460==    by 0xE797C4A: RN_DATA::Add(BOARD_ITEM const*) (stl_vector.h:1024)
==6460==    by 0xE75055E: BOARD::Add(BOARD_ITEM*, int) (class_board.cpp:716)
==6460==    by 0xE6CC695: DIALOG_EXCHANGE_MODULE::Change_1_Module(MODULE*, FPID const&, PICKED_ITEMS_LIST*, bool) (xchgmod.cpp:411)
==6460==    by 0xE6CCDAB: DIALOG_EXCHANGE_MODULE::ChangeCurrentFootprint() (xchgmod.cpp:212)
==6460==    by 0x570A63D: wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const (appbase.cpp:623)
==6460==    by 0x585D3D1: wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) (event.cpp:1384)
==6460==    by 0x585D735: wxEvtHandler::SearchDynamicEventTable(wxEvent&) (event.cpp:1743)
==6460==    by 0x585D7BD: wxEvtHandler::TryHereOnly(wxEvent&) (event.cpp:1577)
==6460==    by 0x585D852: wxEvtHandler::ProcessEventLocally(wxEvent&) (event.h:3671)

Both of them failed while extending the ratnest data vector... of course
the corruption could be in *any* place between the map insert and
RN_DATA::Add.

Maybe some old style printf in RN_DATA::Add will help.

-- 
Lorenzo Marcantonio
Logos Srl


Follow ups

References