← Back to team overview

kicad-developers team mailing list archive

Thoughts on this SCH_COMPONENT::GetField bug?

 

I'm going to investigate this one further, but I don't have time at the 
moment, so I thought I'd ping the group and see if anyone else had a 
thought.

Occasionally, when working with a recently placed component in eeschema, 
I get a crash due to assertion failure. It's this:

#9  0x00007f1591afcbd1 in wxOnAssert (file=0x7f1581aeced8 "/home/cmp/git/kicad/eeschema/sch_component.cpp", line=657, func=0x7f1581aecf1a "GetField", cond=0x7f1581adcf43 "field", msg=0x0) at ./src/common/appbase.cpp:1166
#10 0x00007f15818baae1 in SCH_COMPONENT::GetField (this=0xa68c350, aFieldNdx=-1) at /home/cmp/git/kicad/eeschema/sch_component.cpp:657
#11 0x00007f15818ba0c4 in SCH_COMPONENT::SCH_COMPONENT (this=0xa68c350, aPart=..., sheet=0x1b84760, unit=1, convert=1, pos=..., setNewItemFlag=true) at /home/cmp/git/kicad/eeschema/sch_component.cpp:163
#12 0x00007f158181eb5c in SCH_EDIT_FRAME::Load_Component (this=0x1b7ddf0, aDC=0x7fffdc3226b8, aFilter=0x0, aHistoryList=..., aHistoryLastUnit=@0x7f1581f432c8: 1, aUseLibBrowser=true) at /home/cmp/git/kicad/eeschema/getpart.cpp:223
#13 0x00007f1581885229 in SCH_EDIT_FRAME::OnLeftClick (this=0x1b7ddf0, aDC=0x7fffdc3226b8, aPosition=...) at /home/cmp/git/kicad/eeschema/onleftclick.cpp:300
#14 0x00007f1581903d78 in SCH_EDIT_FRAME::OnSelectTool (this=0x1b7ddf0, aEvent=...) at /home/cmp/git/kicad/eeschema/schedit.cpp:601
#15 0x00007f1591afafd9 in wxAppConsoleBase::HandleEvent (this=0x1926070, handler=0x1b7ddf0, func=(void (wxEvtHandler::*)(wxEvtHandler * const, wxEvent &)) 0x7f1581902640 <SCH_EDIT_FRAME::OnSelectTool(wxCommandEvent&)>, event=...) at ./src/common/appbase.cpp:611

Lines 652-657 in sch_component (this might be offset a bit from yours, I 
have a couple changes in my branch at the moment - unrelated, main 
branch does it too) are:

if( (unsigned) aFieldNdx < m_Fields.size() )
    field = &m_Fields[aFieldNdx];
else
    field = NULL;

wxASSERT( field );


Turns out that aFieldNdx, for whatever reason, is -1. This is passed to 
it directly from the SCH_COMPONENT constructor, which got its own 
indices from LIB_FIELD::GetId(). I've already combed through 
LIB_FIELD::Load and verified that it will not populate an ID with -1, 
and I'm not sure where it's getting set to this. I don't immediately 
have the time to trace it around with watchpoints on m_Id, particularly 
since it doesn't always happen (I haven't been able to find a reliable 
way to reproduce it, other than "just work with a schematic for a 
while").

Possibly of use: the problem field always appears to be a custom field, 
never one of the builtins like reference and value.

--
Chris


Follow ups