← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Fix segfault on quit

 

Wayne, commit this one instead of the destroy() patch - found the 
problem. Also commit the second one, that's a separate (but similar) 
problem.


On Mon, Jun 22, 2015 at 07:41:24PM -0400, Wayne Stambaugh wrote:
> Is this in addition to or instead of your previous patch that removed
> destroy() from ~PGM_BASE()?
> 
> On 6/22/2015 7:04 PM, Chris Pavlina wrote:
> > Under certain (but not all) conditions, kicad applications segfault on 
> > quit. This has been reported:
> > 
> > https://bugs.launchpad.net/kicad/+bug/1431028
> > https://bugs.launchpad.net/kicad/+bug/1467221
> > 
> > It appears to be the case that Pgm().OnPgmExit() was called in the wrong 
> > place. This patch moves it from APP_SINGLE_TOP::OnRun() to 
> > APP_SINGLE_TOP::OnExit(), which appears to correct the issue.
> > 
> > --
> > Chris
> > 
> > 
> > 
> > _______________________________________________
> > 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
> > 
> 
> 
> _______________________________________________
> 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
commit 7360bdf3d29ff8af6070c9e4f8fdc84285974e68
Author: Chris Pavlina <cpavlin1@xxxxxxxxxxxxxx>
Date:   Mon Jun 22 20:56:03 2015 -0400

    Add missing cleanup call to PGM_SINGLE_TOP::OnPgmInit

diff --git a/common/single_top.cpp b/common/single_top.cpp
index c1d8f17..dba849d 100644
--- a/common/single_top.cpp
+++ b/common/single_top.cpp
@@ -278,6 +278,11 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
             // OpenProjectFiles() API asks that it report failure to the UI.
             // Nothing further to say here.
 
+            // We've already initialized things at this point, but wx won't call OnExit if
+            // we fail out. Call our own cleanup routine here to ensure the relevant resources
+            // are freed at the right time (if they aren't, segfaults will occur).
+            OnPgmExit();
+
             // Fail the process startup if the file could not be opened,
             // although this is an optional choice, one that can be reversed
             // also in the KIFACE specific OpenProjectFiles() return value.

Follow ups

References