From 991ff71f3348b4eb828de62ce3dcc0ff205b2e8e Mon Sep 17 00:00:00 2001 From: Armin Schoisswohl Date: Wed, 6 Mar 2024 11:06:50 +0100 Subject: [PATCH] fix deadlock in DRC "Checking keeopouts & disallow constraints" --- pcbnew/pcbexpr_functions.cpp | 5 ++++- pcbnew/zone.cpp | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pcbnew/pcbexpr_functions.cpp b/pcbnew/pcbexpr_functions.cpp index 6b6e123ce7..9d82c175f9 100644 --- a/pcbnew/pcbexpr_functions.cpp +++ b/pcbnew/pcbexpr_functions.cpp @@ -648,7 +648,6 @@ static void intersectsAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self ) if( !aArea->GetBoundingBox().Intersects( itemBBox ) ) return false; - std::unique_lock cacheLock( board->m_CachesMutex ); LSET testLayers; PTR_PTR_LAYER_CACHE_KEY key; @@ -661,6 +660,7 @@ static void intersectsAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self ) { if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 ) { + std::unique_lock cacheLock( board->m_CachesMutex ); key = { aArea, item, layer }; auto i = board->m_IntersectsAreaCache.find( key ); @@ -672,7 +672,10 @@ static void intersectsAreaFunc( LIBEVAL::CONTEXT* aCtx, void* self ) bool collides = collidesWithArea( item, context, aArea ); if( ( item->GetFlags() & ROUTER_TRANSIENT ) == 0 ) + { + std::unique_lock cacheLock( board->m_CachesMutex ); board->m_IntersectsAreaCache[ key ] = collides; + } if( collides ) return true; diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index fe642aaa48..3c6bc16bed 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -368,9 +368,7 @@ void ZONE::CacheBoundingBox() auto cacheIter = cache.find( this ); if( cacheIter == cache.end() ) - { cache[ this ] = m_Poly->BBox(); - } }