Pcbnew crashes on exit in Opengl mode when a footprint on the board was edited in the fp editor

Bug #1655858 reported by jean-pierre charras
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Critical
jean-pierre charras

Bug Description

Application: kicad
Version: (2017-01-11 revision e99b79c)-master, release build
Libraries: wxWidgets 3.1
           libcurl/7.50.3 OpenSSL/1.0.2j zlib/1.2.8 libidn/1.33 libssh2/1.7.0 nghttp2/1.15.0 librtmp/2.3
Platform: Windows 7 (build 7601, Service Pack 1), 32 bit, Little endian, wxMSW
- Build Info -
wxWidgets: 3.1.0 (wchar_t,wx containers)
Boost: 1.62.0
Curl: 7.51.0
KiCad - Compiler: GCC 6.2.0 with C++ ABI 1010
        Settings: USE_WX_GRAPHICS_CONTEXT=OFF
                  USE_WX_OVERLAY=OFF
                  KICAD_SCRIPTING=ON
                  KICAD_SCRIPTING_MODULES=ON
                  KICAD_SCRIPTING_WXPYTHON=OFF
                  BUILD_GITHUB_PLUGIN=ON
                  KICAD_USE_SCH_IO_MANAGER=ON
                  KICAD_USE_OCE=ON

In Opengl mode only (not in legacy mode, not in Cairo mode)Pcbnew always crashes on exit when a footprint on the board was edited in the fp editor.
To reproduce (OpenGL mode)

Run Pcbnew.
From the board editor try to edit a footprint on the board using the footprint editor (Ctrl E).
Close the fp editor (no need to edit something)
Now close the board editor: the crash happens (when run from kicad, sometimes the crash happens when closing Kicad).

Revision history for this message
Maciej Suminski (orsonmmz) wrote :

I have just tried with Linux and Win7 x64 and I cannot reproduce the problem. The only difference in my builds is disabled scripting and OCE, but I do not suspect them.

Does it really happen with all boards? Can anyone else reproduce in on another platform?

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

Foe me:
It happens with any board on W7 (32 bits).
It does not happen on my Linux Kubuntu install.

Revision history for this message
Chris Pavlina (pavlina-chris) wrote :

There are a lot of weird, hard-to-reproduce crashes having to do with both footprints and symbols that have been edited in place during the current session...

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

More info about the crash:

It happens only if the edited footprint in the footprint editor is still selected in the board editor when closing it.
If, after edition, I unselect it (for instance by selection an other footprint), the crash does not happen.

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

It looks like a very recent fix has also fixed this crash:

This version:
Application: kicad
Version: (2017-01-13 revision 99bfa2f)-master, release build
Libraries: wxWidgets 3.1
           libcurl/7.50.3 OpenSSL/1.0.2j zlib/1.2.8 libidn/1.33 libssh2/1.7.0 nghttp2/1.15.0 librtmp/2.3
Platform: Windows 7 (build 7601, Service Pack 1), 32 bit, Little endian, wxMSW

does not crash.

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

Sorry: it is not fixed:
I was just in Cairo mode, which does not crash. in Opengl mode the crash is still here.

Changed in kicad:
importance: Undecided → Critical
Revision history for this message
jean-pierre charras (jp-charras) wrote :

I made some tests.
the commit which created this issue is :
27a10e8597deb7788428a20a77fdf98037e8d61b (Tomasz Wlostowski, 04/11/2016)

Note also:
There is no backtrace on GDB after the crash.
The crash happens when the fp editor is closed before the board editor, but if the board editor is closed before the fp editor, there is no crash.

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

@Tomasz:

It looks like a event is fired after the frame is deleted.

if, in void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) I call:
GetGalCanvas()->SetEvtHandlerEnabled( false );

the crash does not happen anymore.
(If it is really a event issue, it is not surprising it happens only on a given OS)

Is it the right way to fix the crash (at least it is a workaround) ?

Revision history for this message
Maciej Suminski (orsonmmz) wrote :

Jean-Pierre,

Thank you for investigating the issue, it is really hard to fix problems that cannot be reproduced.

Do you know what kind of event is causing the problem? Is it a wxWidgets or TOOL_EVENT? I would be grateful for backtrace, if it is available.

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

I don't really know the kind of event.
And the crash happens after the PCB_EDIT_FRAME destructor is called.
Unfortunately the backtrace is empty (no backtrace)
This is unfortunately frequently the case with GDB on windows.

"it is really hard to fix problems that cannot be reproduced"
Well, I know...

However we have a workaround.

Revision history for this message
Maciej Suminski (orsonmmz) wrote :

Jean-Pierre,

I think this is acceptable for the moment, as there is no other easy way to fix it. I could start throwing patches blindly, but I imagine it would be a waste of time for both us. Please add it with a link to this bug report, so we know why the line is there.

Once again, thank you for your help here.

Revision history for this message
KiCad Janitor (kicad-janitor) wrote :

Fixed in revision fef40c96e2f4aced8413828a84b16a84653b8e85
https://git.launchpad.net/kicad/patch/?id=fef40c96e2f4aced8413828a84b16a84653b8e85

Changed in kicad:
status: New → Fix Committed
assignee: nobody → jean-pierre charras (jp-charras)
Jeff Young (jeyjey)
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.