← Back to team overview

kicad-developers team mailing list archive

Re: Uninitialised ZONE_CONTAINER members

 

Le 16/04/2019 à 19:36, John Beard a écrit :
> Hi JP,
> 
> I think the problem is that the members *within* ZONE_CONTAINER are
> uninitialised, but they are accessed by the very act of trying to set
> them from ZONE_SETTINGS::ExportSetting. If they had a spurious value
> that was the same as the new value, the refill would not happen.

Good catch!

Well, this is a subtle "bug" that does not create actual issues.
min thickness could be set to ZONE_THICKNESS_MIL (10mil),
m_ThermalReliefCopperBridge could be set to ZONE_THERMAL_RELIEF_GAP_MIL
(20mil),
before calling aBoard->GetZoneSettings().ExportSetting( *this );
in class_zone.cpp

See zones.h
(These values are certainly a bit too large, nowadays)

About refill, if we need a refill, it should be *clearly* called.

> 
> The call stacks are as follows:
> 
> ==12798== Conditional jump or move depends on uninitialised value(s)
> ==12798==    at 0x7CA4F4: ZONE_CONTAINER::SetMinThickness(int)
> (class_zone.h:203)
> ==12798==    by 0xD752CE:
> ZONE_SETTINGS::ExportSetting(ZONE_CONTAINER&, bool) const
> (zone_settings.cpp:121)
> ==12798==    by 0xCF2AE0: ZONE_CONTAINER::ZONE_CONTAINER(BOARD*)
> (class_zone.cpp:76)
> ==12798==    by 0xD57E0E: PCB_PARSER::parseZONE_CONTAINER()
> (pcb_parser.cpp:3057)
> ==12798==    by 0xD4A86B: PCB_PARSER::parseBOARD_unchecked()
> (pcb_parser.cpp:570)
> ==12798==    by 0xD4A3CD: PCB_PARSER::parseBOARD() (pcb_parser.cpp:486)
> ==12798==    by 0xD4A0E9: PCB_PARSER::Parse() (pcb_parser.cpp:465)
> 
> ==12798== Conditional jump or move depends on uninitialised value(s)
> ==12798==    at 0xB299D2:
> ZONE_CONTAINER::SetThermalReliefCopperBridge(int) (class_zone.h:178)
> ==12798==    by 0xD7537C:
> ZONE_SETTINGS::ExportSetting(ZONE_CONTAINER&, bool) const
> (zone_settings.cpp:129)
> ==12798==    by 0xCF2AE0: ZONE_CONTAINER::ZONE_CONTAINER(BOARD*)
> (class_zone.cpp:76)
> ==12798==    by 0xD57E0E: PCB_PARSER::parseZONE_CONTAINER()
> (pcb_parser.cpp:3057)
> ==12798==    by 0xD4A86B: PCB_PARSER::parseBOARD_unchecked()
> (pcb_parser.cpp:570)
> ==12798==    by 0xD4A3CD: PCB_PARSER::parseBOARD() (pcb_parser.cpp:486)
> ==12798==    by 0xD4A0E9: PCB_PARSER::Parse() (pcb_parser.cpp:465)
> 
> Cheers,
> 
> John
> 
> On Tue, Apr 16, 2019 at 5:38 PM jp charras <jp.charras@xxxxxxxxxx> wrote:
>>
>> Le 16/04/2019 à 17:59, John Beard a écrit :
>>> Hi,
>>>
>>> The following members are not initialised in ZONE_CONTAINER's
>>> constructor, but they are accessed in the Setter functions:
>>>
>>> * m_ThermalReliefCopperBridge
>>> * m_ZoneMinThickness
>>>
>>> This was picked up with valgrind memcheck:
>>>
>>> valgrind --tool=memcheck qa/pcbnew_tools/qa_pcbnew_tools pcb_parser
>>> /tmp/ciaa_acc.kicad_pcb
>>>
>>> What would be sensible defaults here? 0?
>>>
>>> Cheers,
>>>
>>> John
>>>
>>
>> Strange: these parameters come from ZONE_SETTINGS class, and they are
>> initialized in the ZONE_SETTINGS ctor ( min thickness 10mil,
>> m_ThermalReliefCopperBridge 20mils ).
>>
>>
>> --
>> Jean-Pierre CHARRAS
>>
>> _______________________________________________
>> 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
> 


-- 
Jean-Pierre CHARRAS


References