← Back to team overview

kicad-developers team mailing list archive

Re: Bug 1834718

 

Hi Wayne-

Thanks for testing. If you have a chance, can you give the attached patch a spin? This is in place of the previous attempt.

Best-
Seth

On 2019-07-01 07:51, Wayne Stambaugh wrote:
Hey Seth,

No bueno.  Here is the back trace using your patch.

Cheers,

Wayne

#41640 0x000000006d26fb1d in ?? ()
   from E:\msys64\mingw64\bin\wxmsw30u_core_gcc_custom.dll
#41641 0x00000000806e8747 in WX_PROGRESS_REPORTER::~WX_PROGRESS_REPORTER (
    this=0x12884860, __in_chrg=<optimized out>)
    at
E:/msys64/home/Wayne/src/kicad-5.1/common/widgets/progress_reporter.cpp:117
#41642 0x00000000806e8785 in WX_PROGRESS_REPORTER::~WX_PROGRESS_REPORTER (
    this=0x12884860, __in_chrg=<optimized out>)
    at
E:/msys64/home/Wayne/src/kicad-5.1/common/widgets/progress_reporter.cpp:118
#41643 0x00000000809da798 in
std::default_delete<WX_PROGRESS_REPORTER>::operator() (this=0x1539f138,
__ptr=0x12884860)
    at E:/msys64/mingw64/include/c++/9.1.0/bits/unique_ptr.h:81
#41644 0x0000000080a24454 in std::unique_ptr<WX_PROGRESS_REPORTER,
std::default_delete<WX_PROGRESS_REPORTER> >::~unique_ptr (this=0x1539f138,
    __in_chrg=<optimized out>)
    at E:/msys64/mingw64/include/c++/9.1.0/bits/unique_ptr.h:289
#41645 0x00000000802e4b26 in ZONE_FILLER_TOOL::ZoneFill (this=0x14338300,
    aEvent=...)
    at
E:/msys64/home/Wayne/src/kicad-5.1/pcbnew/tools/zone_filler_tool.cpp:103
#41646 0x0000000080bc7b4f in std::__invoke_impl<int, int
(ZONE_FILLER_TOOL::*&)(TOOL_EVENT const&), ZONE_FILLER_TOOL*&,
TOOL_EVENT const&> (__f=
    @0x182d4800: (int (ZONE_FILLER_TOOL::*)(class ZONE_FILLER_TOOL *
const, const class TOOL_EVENT &)) 0x802e4888
<ZONE_FILLER_TOOL::ZoneFill(TOOL_EVENT const&)>, __t=@0x182d4810:
0x14338300, __args#0=...)
    at E:/msys64/mingw64/include/c++/9.1.0/bits/invoke.h:73
#41647 0x0000000080c17723 in std::__invoke<int
(ZONE_FILLER_TOOL::*&)(TOOL_EVENT const&), ZONE_FILLER_TOOL*&,
TOOL_EVENT const&> (__fn=
    @0x182d4800: (int (ZONE_FILLER_TOOL::*)(class ZONE_FILLER_TOOL *
const, const class TOOL_EVENT &)) 0x802e4888
<ZONE_FILLER_TOOL::ZoneFill(TOOL_EVENT const&)>, __args#0=@0x182d4810:
0x14338300, __args#1=...)
    at E:/msys64/mingw64/include/c++/9.1.0/bits/invoke.h:95
#41648 0x0000000080ab5bcb in std::_Bind<int
(ZONE_FILLER_TOOL::*(ZONE_FILLER_TOOL*,
std::_Placeholder<1>))(TOOL_EVENT const&)>::__call<int, TOOL_EVENT
const&, 0ull, 1ull>(std::tuple<TOOL_EVENT const&>&&,
std::_Index_tuple<0ull, 1ull>) (
    this=0x182d4800, __args=...)
    at E:/msys64/mingw64/include/c++/9.1.0/functional:400
#41649 0x0000000080ab5cf4 in std::_Bind<int
(ZONE_FILLER_TOOL::*(ZONE_FILLER_TOOL*,
std::_Placeholder<1>))(TOOL_EVENT const&)>::operator()<TOOL_EVENT
const&, int>(TOOL_EVENT const&) (this=0x182d4800, __args#0=...)
    at E:/msys64/mingw64/include/c++/9.1.0/functional:484
#41650 0x0000000080a90269 in std::_Function_handler<int (TOOL_EVENT
const&), std::_Bind<int (ZONE_FILLER_TOOL::*(ZONE_FILLER_TOOL*,
std::_Placeholder<1>))(TOOL_EVENT const&)> >::_M_invoke(std::_Any_data
const&, TOOL_EVENT const&) (
    __functor=..., __args#0=...)
    at E:/msys64/mingw64/include/c++/9.1.0/bits/std_function.h:285
#41651 0x0000000080a01b9b in std::function<int (TOOL_EVENT
const&)>::operator()(TOOL_EVENT const&) const (this=0x182d2db8,
__args#0=...)
    at E:/msys64/mingw64/include/c++/9.1.0/bits/std_function.h:690
#41652 0x000000008095920a in COROUTINE<int, TOOL_EVENT const&>::callerStub (
    aData=354023872)
    at E:/msys64/home/Wayne/src/kicad-5.1/include/tool/coroutine.h:331
#41653 0x00000000807b8f4a in make_fcontext ()
   from E:\msys64\mingw64\bin\_pcbnew.kiface
#41654 0x000000001519f9c0 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)


On 6/29/2019 3:17 PM, Seth Hillbrand wrote:
Hi Wayne-

That actually helps a lot.  It also explains why this is MSW-only behavior.

I'm attaching a patch that should address this.  Let me know if it
doesn't help.

Best-
Seth

On 2019-06-29 11:48, Wayne Stambaugh wrote:
Seth,

I managed to let the gdb back trace finish.  It took a while but here is
the last of the stack up to the last progress dialog dtor iteration.
I'm not sure how much good it's going to do.  It looks like there was a context switch or something that corrupted the previous stack frame so
any useful information in that stack frame is lost :(

Wayne

#83262 0x000000006d26fb1d in ?? ()
   from E:\msys64\mingw64\bin\wxmsw30u_core_gcc_custom.dll
#83263 0x00000000806e8547 in
WX_PROGRESS_REPORTER::~WX_PROGRESS_REPORTER (
    this=0x1751aca0, __in_chrg=<optimized out>)
    at
E:/msys64/home/Wayne/src/kicad-5.1/common/widgets/progress_reporter.cpp:117

#83264 0x00000000802d2d88 in POINT_EDITOR::finishItem (this=0x12a8a3a0)
    at
E:/msys64/home/Wayne/src/kicad-5.1/pcbnew/tools/point_editor.cpp:650
#83265 0x00000000802d15a0 in POINT_EDITOR::OnSelectionChange (
    this=0x12a8a3a0, aEvent=...)
    at
E:/msys64/home/Wayne/src/kicad-5.1/pcbnew/tools/point_editor.cpp:427
#83266 0x0000000080bc764f in std::__invoke_impl<int, int
(POINT_EDITOR::*&)(TOOL_EVENT const&), POINT_EDITOR*&, TOOL_EVENT
const&> (__f=
    @0x190138a0: (int (POINT_EDITOR::*)(class POINT_EDITOR * const,
const class TOOL_EVENT &)) 0x802d0b22
<POINT_EDITOR::OnSelectionChange(TOOL_EVENT const&)>, __t=@0x190138b0:
0x12a8a3a0, __args#0=...)
    at E:/msys64/mingw64/include/c++/9.1.0/bits/invoke.h:73
#83267 0x0000000080c172b3 in std::__invoke<int
(POINT_EDITOR::*&)(TOOL_EVENT const&), POINT_EDITOR*&, TOOL_EVENT
const&> (__fn=
    @0x190138a0: (int (POINT_EDITOR::*)(class POINT_EDITOR * const,
const class TOOL_EVENT &)) 0x802d0b22
<POINT_EDITOR::OnSelectionChange(TOOL_EVENT const&)>,
__args#0=@0x190138b0: 0x12a8a3a0, __args#1=...)
    at E:/msys64/mingw64/include/c++/9.1.0/bits/invoke.h:95
#83268 0x0000000080ab4fcb in std::_Bind<int
(POINT_EDITOR::*(POINT_EDITOR*, std::_Placeholder<1>))(TOOL_EVENT
const&)>::__call<int, TOOL_EVENT const&, 0ull,
1ull>(std::tuple<TOOL_EVENT const&>&&, std::_Index_tuple<0ull, 1ull>) (
    this=0x190138a0, __args=...)
    at E:/msys64/mingw64/include/c++/9.1.0/functional:400
#83269 0x0000000080ab50f4 in std::_Bind<int
(POINT_EDITOR::*(POINT_EDITOR*, std::_Placeholder<1>))(TOOL_EVENT
const&)>::operator()<TOOL_EVENT const&, int>(TOOL_EVENT const&)
(this=0x190138a0, __args#0=...)
    at E:/msys64/mingw64/include/c++/9.1.0/functional:484
#83270 0x0000000080a8fef9 in std::_Function_handler<int (TOOL_EVENT
const&), std::_Bind<int (POINT_EDITOR::*(POINT_EDITOR*,
std::_Placeholder<1>))(TOOL_EVENT const&)> >::_M_invoke(std::_Any_data
const&, TOOL_EVENT const&) (
    __functor=..., __args#0=...)
    at E:/msys64/mingw64/include/c++/9.1.0/bits/std_function.h:285
#83271 0x0000000080a0196b in std::function<int (TOOL_EVENT
const&)>::operator()(TOOL_EVENT const&) const (this=0x19011718,
__args#0=...)
    at E:/msys64/mingw64/include/c++/9.1.0/bits/std_function.h:690
#83272 0x0000000080958ffa in COROUTINE<int, TOOL_EVENT
const&>::callerStub (
    aData=401672480)
    at E:/msys64/home/Wayne/src/kicad-5.1/include/tool/coroutine.h:332
#83273 0x00000000807b8d4a in make_fcontext ()
   from E:\msys64\mingw64\bin\_pcbnew.kiface
#83274 0x0000000017f10920 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)


On 6/28/2019 7:58 PM, Seth Hillbrand wrote:
Hi Wayne-

I can't get Linux to crash for this bug but I do see some memory access
grinding when I follow your steps.

Can you test the attached patch and see if it fixes the issue for you? 
Launchpad is down right now, so I can't attach it to the bug report.

This patch should not be committed to the tree.  If it fixes the issue,
we can address the root cause but that's a bigger job.

-Seth
From ff066c5af99ba83acfdef7bda860b2a64d9b8623 Mon Sep 17 00:00:00 2001
From: Seth Hillbrand <hillbrand@xxxxxxxxxxx>
Date: Sat, 29 Jun 2019 12:14:43 -0700
Subject: [PATCH] Move zone refill to action

This unifies the zone refill across architecture into the tool-based
architecture.
---
 pcbnew/tools/point_editor.cpp     | 16 +----------
 pcbnew/tools/zone_filler_tool.cpp | 46 ++++++++++++++++++-------------
 2 files changed, 28 insertions(+), 34 deletions(-)

diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp
index 2b06c4a4e..2da09d751 100644
--- a/pcbnew/tools/point_editor.cpp
+++ b/pcbnew/tools/point_editor.cpp
@@ -637,21 +637,7 @@ void POINT_EDITOR::finishItem()
         auto zone = static_cast<ZONE_CONTAINER*>( item );
 
         if( zone->IsFilled() && m_refill )
-        {
-            ZONE_FILLER filler( board() );
-            // A progress reporter can be usefull. However it works fine only on Windows
-            // so enable it only on Windows.
-            // On Linux, the filled areas are incorrectly shown: the insulated islands
-            // remain displayed, although they are removed from the actual filled areas list
-            //
-            // Fix me: try to make it working on Linux.
-            //
-            #ifdef __WINDOWS__
-            WX_PROGRESS_REPORTER reporter( getEditFrame<PCB_BASE_FRAME>(), _( "Refill Zones" ), 4 );
-            filler.SetProgressReporter( &reporter );
-            #endif
-            filler.Fill( { zone } );
-        }
+            m_toolMgr->RunAction( PCB_ACTIONS::zoneFill, true, zone );
     }
 }
 
diff --git a/pcbnew/tools/zone_filler_tool.cpp b/pcbnew/tools/zone_filler_tool.cpp
index ea208606e..e5b44fb30 100644
--- a/pcbnew/tools/zone_filler_tool.cpp
+++ b/pcbnew/tools/zone_filler_tool.cpp
@@ -84,22 +84,29 @@ int ZONE_FILLER_TOOL::ZoneFill( const TOOL_EVENT& aEvent )
 
     BOARD_COMMIT commit( this );
 
-    for( auto item : selection() )
+    if( auto passedZone = aEvent.Parameter<ZONE_CONTAINER*>() )
     {
-        assert( item->Type() == PCB_ZONE_AREA_T );
-
-        ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*> ( item );
-
-        toFill.push_back(zone);
+        if( passedZone->Type() == PCB_ZONE_AREA_T )
+            toFill.push_back( passedZone );
+    }
+    else
+    {
+        for( auto item : selection() )
+        {
+            if( auto zone = dyn_cast<ZONE_CONTAINER*>( item ) )
+                toFill.push_back( zone );
+        }
     }
 
-    std::unique_ptr<WX_PROGRESS_REPORTER> progressReporter(
-            new WX_PROGRESS_REPORTER( frame(), _( "Fill Zone" ), 4 )
-            );
+    // Set the RAII scope here to force the dtor before we refresh the tool
+    {
+        auto progressReporter = std::make_unique<WX_PROGRESS_REPORTER>
+            ( frame(), _( "Fill Zone" ), 4 );
 
-    ZONE_FILLER filler( board(), &commit );
-    filler.SetProgressReporter( progressReporter.get() );
-    filler.Fill( toFill );
+        ZONE_FILLER filler( board(), &commit );
+        filler.SetProgressReporter( progressReporter.get() );
+        filler.Fill( toFill );
+    }
 
     canvas()->Refresh();
 
@@ -118,15 +125,16 @@ int ZONE_FILLER_TOOL::ZoneFillAll( const TOOL_EVENT& aEvent )
         toFill.push_back(zone);
     }
 
-    std::unique_ptr<WX_PROGRESS_REPORTER> progressReporter(
-            new WX_PROGRESS_REPORTER( frame(), _( "Fill All Zones" ), 4 )
-            );
+    {
+        auto progressReporter = std::make_unique<WX_PROGRESS_REPORTER>
+            ( frame(), _( "Fill All Zones" ), 4 );
 
-    ZONE_FILLER filler( board(), &commit );
-    filler.SetProgressReporter( progressReporter.get() );
+        ZONE_FILLER filler( board(), &commit );
+        filler.SetProgressReporter( progressReporter.get() );
 
-    if( filler.Fill( toFill ) )
-        frame()->m_ZoneFillsDirty = false;
+        if( filler.Fill( toFill ) )
+            frame()->m_ZoneFillsDirty = false;
+    }
 
     canvas()->Refresh();
 
-- 
2.20.1


Follow ups

References