Pcbnew crashes when opening 3D view

Bug #1437930 reported by miceuz
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Critical
Unassigned

Bug Description

For this particular one board I'm attaching.

I'm on 64-bit Linux Mint, build no 5549

Tags: 3d-viewer
Revision history for this message
miceuz (mic-j) wrote :
Revision history for this message
firewalker (firew4lker) wrote :

Confirmed in 32 bit also (r5550).

Segmentation fault.

Application: kicad
Version: (2015-03-29 BZR 5550)-product Release build
wxWidgets: Version 3.0.2 (debug,wchar_t,compiler with C++ ABI 1002,GCC 4.9.2,wx containers,compatible with 2.8)
Platform: Linux 3.19.2-1-ARCH i686, 32 bit, Little endian, wxGTK
Boost version: 1.54.0
         USE_WX_GRAPHICS_CONTEXT=OFF
         USE_WX_OVERLAY=OFF
         KICAD_SCRIPTING=ON
         KICAD_SCRIPTING_MODULES=ON
         KICAD_SCRIPTING_WXPYTHON=ON
         USE_FP_LIB_TABLE=HARD_CODED_ON
         BUILD_GITHUB_PLUGIN=ON
         KICAD_USE_WEBKIT=ON

Revision history for this message
Nick Østergaard (nickoe) wrote :

Can you get a backtrace, I can not reproduce.

You can do:

gdb --args pcbnew /path/to/ultimate-temp-controller.kicad_pcb

Then 1. run, 2. open 3d viewer where it crashed, 3. type bt in the prompt and copy and pate the trace here, would be good in an attached file if long.

Changed in kicad:
importance: Undecided → Critical
tags: added: 3d-viewer
Revision history for this message
Nick Østergaard (nickoe) wrote :

I can reproduce with the version info below. The one where I could not reproduce was made the day before I think. I don't know the exact rev, because I did not ensure to update the version.h file. Trace from release build does not seems that usefull, I will try to build a debug build an post my backtrace.

Application: pcbnew
Version: (2015-03-30 BZR 5554)-kicad Release build
wxWidgets: Version 3.0.2 (debug,wchar_t,compiler with C++ ABI 1002,GCC 4.9.2,wx containers,compatible with 2.8)
Platform: Linux 3.19.2-1-ARCH x86_64, 64 bit, Little endian, wxGTK
Boost version: 1.57.0
         USE_WX_GRAPHICS_CONTEXT=OFF
         USE_WX_OVERLAY=OFF
         KICAD_SCRIPTING=ON
         KICAD_SCRIPTING_MODULES=ON
         KICAD_SCRIPTING_WXPYTHON=ON
         USE_FP_LIB_TABLE=HARD_CODED_ON
         BUILD_GITHUB_PLUGIN=ON
         KICAD_USE_WEBKIT=OFF

Revision history for this message
Wayne Stambaugh (stambaughw) wrote : Re: [Bug 1437930] Re: Pcbnew crashes when opening 3D view

Hey Nick,

Sorry about the late reply but I was looking at this patch today and it
will need to be modified to work with the new stable version numbering
code I will have to add to support the upcoming stable release. I also
have a fix for the version.h file not getting updated correctly so you
may want to wait until I commit those changes and refactor your patch
accordingly.

Thanks,

Wayne

On 3/30/2015 3:17 PM, Nick Østergaard wrote:
> I can reproduce with the version info below. The one where I could not
> reproduce was made the day before I think. I don't know the exact rev,
> because I did not ensure to update the version.h file. Trace from
> release build does not seems that usefull, I will try to build a debug
> build an post my backtrace.
>
> Application: pcbnew
> Version: (2015-03-30 BZR 5554)-kicad Release build
> wxWidgets: Version 3.0.2 (debug,wchar_t,compiler with C++ ABI 1002,GCC 4.9.2,wx containers,compatible with 2.8)
> Platform: Linux 3.19.2-1-ARCH x86_64, 64 bit, Little endian, wxGTK
> Boost version: 1.57.0
> USE_WX_GRAPHICS_CONTEXT=OFF
> USE_WX_OVERLAY=OFF
> KICAD_SCRIPTING=ON
> KICAD_SCRIPTING_MODULES=ON
> KICAD_SCRIPTING_WXPYTHON=ON
> USE_FP_LIB_TABLE=HARD_CODED_ON
> BUILD_GITHUB_PLUGIN=ON
> KICAD_USE_WEBKIT=OFF
>

Revision history for this message
Nick Østergaard (nickoe) wrote :

I reproduced with the debug build rev 5554. Attached is the backtrace.

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

Please ignore my post. I answered the wrong email. Duh!

Revision history for this message
jean-pierre charras (jp-charras) wrote :

This is the known bug in boost::polygon which creates this crash.
Unfortunately it is not yet fixed, and cannot be fixed bu us.

Revision history for this message
Mario Luzeiro (mrluzeiro) wrote :

I know what is causing this bug.
Jean-pierre:

Considering this is the cause of the bug:
    // Number of segments to convert a circle to polygon
    // Boost polygon (at least v 1.54, v1.55 and previous) in very rare cases crashes
    // when using 16 segments to approximate a circle.
    // So using 18 segments is a workaround to try to avoid these crashes

Then in this line:
775 pad->BuildPadDrillShapePolygon( allLayerHoles, 0,
                                                    (int)(segcountLowQuality * segFactor) );

We need to make sure that the value is not 16, something like:
nrSeg = (int)(segcountLowQuality * segFactor);

if( nrSeg == 16 )
    nrSeg = 15;

:)
I will on holidays away from the computer to test and patch it, I appreciate if you can fix it for me!

Revision history for this message
jean-pierre charras (jp-charras) wrote :

No, this is not the cause.
This is a bug in boost::polygon which happens rarely, and depends on the shape of polygons.

When using a value which differs from 16 to approximate circles by polygons, it happens less frequently, but it happens.

In this case, because most of polygons do not have 16 segments, and your patch (I tested it) has no effect.

Usually, just slightly changing a parameter (for instance zone clearance) modify the polygon shapes and avoid the crash.

Revision history for this message
Nick Østergaard (nickoe) wrote :

@Jean-Pierre, why does this not happen on the other build I had earlier?

Revision history for this message
Eric (e-kolker) wrote :

The viewer worked for me as of yesterday's build, but when I downloaded today's nightly it broke. To be clear, nothing changed about the PCB file overnight.

Backtrace attached, project files available here: https://github.com/tessel/tessel-v2-hardware (commit hash 10bb7155e8dc4be78932c26390652a3ad72f7c0b)

Revision history for this message
miceuz (mic-j) wrote :

For me it started manifesting after commit 5548 -- it has something to do with 3D viewer

Revision history for this message
jean-pierre charras (jp-charras) wrote :

Again, this is a bug in boost::polygon which happens rarely, and *depends on the shape of polygons*

Commit 5548 slightly changed the shape of polygons which approximate a circle (changed the number of segments).
This board crashes, and perhaps boards which previously crashed in 3D viewer are now working.

You easily verify by changing the clearance of the zone on the back side, i.e. the shape of polygons, the crash does not happen.

The way the circles are approximated will be changed soon, but it will not fix anything, although this board will not crash anymore.

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

If I'm reading this back trace correctly, it appears that something in a
std::list is being freed from memory more than once. Here is the error
I get in gdb on a 64 bit build against boost 1.57 on windows:

#0 0x00000000109c9320 in std::list<boost::polygon::point_data<int>,
std::allocator<boost::polygon::point_data<int> > >::begin
(this=0xfeeefeeefeeefeee)
    at C:/msys64/mingw64/include/c++/4.9.2/bits/stl_list.h:772

On 3/31/2015 3:16 PM, jean-pierre charras wrote:
> Again, this is a bug in boost::polygon which happens rarely, and
> *depends on the shape of polygons*
>
> Commit 5548 slightly changed the shape of polygons which approximate a circle (changed the number of segments).
> This board crashes, and perhaps boards which previously crashed in 3D viewer are now working.
>
> You easily verify by changing the clearance of the zone on the back
> side, i.e. the shape of polygons, the crash does not happen.
>
> The way the circles are approximated will be changed soon, but it will
> not fix anything, although this board will not crash anymore.
>

Revision history for this message
Nick Østergaard (nickoe) wrote :

A fix for this has been committed from Tomasz in 5741. Please retest to verify and see https://lists.launchpad.net/kicad-developers/msg18596.html

Revision history for this message
Nick Østergaard (nickoe) wrote :

Tested with 5762, but please retest miceuz.

Changed in kicad:
status: New → Fix Committed
Revision history for this message
miceuz (mic-j) wrote :

Looks good with 5755. Thanks!

Jon Neal (reportingsjr)
Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.