← Back to team overview

kicad-developers team mailing list archive

pcbnew crash when pad clearance "too negative"

 

Hi all,

I experience a crash in pcbnew when pad clearance is "too negative"
according to the pad shape.

To reproduce:
- Open pcbnew (In OpenGL canvas)
- Open footprint editor
- Create a new footprint
- Place a new SMD rectangular PAD of 1.5mmx1.5mm size
- Change footprint properties and set "Pad clearance" to -1 (in mm)
=> pcbnew crash

It is crashing because at pcbnew/pcb_painter.cpp:777 a polyset is filled
based on shape and clearance:

aPad->TransformShapeWithClearanceToPolygon ...

But in this case (parameter of clearance) the returned polyset is empty

so code at pcbnew/pcb_painter.cpp:783

m_gal->DrawPolyline( polySet.COutline( 0 ) );

always crash because polySet has an empty m_poly property (crash in
COutline in fact...).

To fix this:
Check polySet is not empty:

        if( polySet.OutlineCount() > 0 )
             m_gal->DrawPolyline( polySet.COutline( 0 ) );

other solution:
Modify SHAPE_POLY_SET::COutline(int aIndex)
(include/geometry/shape_poly_set.h:190)
To deny "aIndex" out of range values...


An other solution:
Perhaps it's not logical to allow negative values but in this case
interface should deny enter a negative value (and check existing values
from footprint/schematics...)...



Application: pcbnew
Version: no-vcs-found-7613~59~ubuntu16.04.1-experimental, release build
Libraries: wxWidgets 3.0.2
           libcurl/7.47.0 OpenSSL/1.0.2g zlib/1.2.8 libidn/1.32 librtmp/2.3
Platform: Linux 4.4.0-62-generic x86_64, 64 bit, Little endian, wxGTK
- Build Info -
wxWidgets: 3.0.2 (wchar_t,wx containers,compatible with 2.8)
Boost: 1.58.0
Curl: 7.47.0
KiCad - Compiler: GCC 5.4.0 with C++ ABI 1009
        Settings: USE_WX_GRAPHICS_CONTEXT=OFF
                  USE_WX_OVERLAY=OFF
                  KICAD_SCRIPTING=ON
                  KICAD_SCRIPTING_MODULES=ON
                  KICAD_SCRIPTING_WXPYTHON=ON
                  KICAD_SCRIPTING_ACTION_MENU=ON
                  BUILD_GITHUB_PLUGIN=ON
                  KICAD_USE_SCH_IO_MANAGER=ON
                  KICAD_USE_OCE=ON


Follow ups