From 8cd8bc7b0604d03511bb318ab2dc4c050e214562 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Sun, 4 Jun 2023 20:49:02 +0200 Subject: [PATCH] another fix of a race-condition --- .../include/CGAL/Spatial_lock_grid_3.h | 2 +- .../include/CGAL/Regular_triangulation_3.h | 20 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/STL_Extension/include/CGAL/Spatial_lock_grid_3.h b/STL_Extension/include/CGAL/Spatial_lock_grid_3.h index b50211b0199..58737d76191 100644 --- a/STL_Extension/include/CGAL/Spatial_lock_grid_3.h +++ b/STL_Extension/include/CGAL/Spatial_lock_grid_3.h @@ -209,7 +209,7 @@ public: int index_x = static_cast( (CGAL::to_double(point.x()) - m_bbox.xmin()) * m_resolution_x); //index_x = std::max( 0, std::min(index_x, m_num_grid_cells_per_axis - 1) ); index_x = - (index_x < 0 ? + (index_x < 0 ? /// @TODO: use std::clamp 0 : (index_x >= m_num_grid_cells_per_axis ? m_num_grid_cells_per_axis - 1 diff --git a/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Triangulation_3/include/CGAL/Regular_triangulation_3.h index 072a3795e94..bc999c178a9 100644 --- a/Triangulation_3/include/CGAL/Regular_triangulation_3.h +++ b/Triangulation_3/include/CGAL/Regular_triangulation_3.h @@ -2584,8 +2584,17 @@ remove(Vertex_handle v, bool *could_lock_zone) if(!vertex_validity_check(v, tds())) return true; // vertex is already gone from the TDS, nothing to do - Vertex_handle hint = v->cell()->vertex(0) == v ? v->cell()->vertex(1) : v->cell()->vertex(0); - +#ifndef CGAL_LINKED_WITH_TBB + using Vertex_handle_and_point = Vertex_handle; +#endif // not CGAL_LINKED_WITH_TBB + Vertex_handle_and_point hint_and_point{v->cell()->vertex(0) == v ? v->cell()->vertex(1) : v->cell()->vertex(0)}; +#ifdef CGAL_LINKED_WITH_TBB + const Vertex_handle& hint = hint_and_point.vh; + const Weighted_point& hint_point_mem = hint_and_point.wpt; +#else // not CGAL_LINKED_WITH_TBB + const Vertex_handle& hint = hint_and_point; + const Weighted_point& hint_point_mem = hint_and_point->point(); +#endif // not CGAL_LINKED_WITH_TBB Self tmp; Vertex_remover remover(tmp); removed = Tr_Base::remove(v, remover, could_lock_zone); @@ -2612,13 +2621,12 @@ remove(Vertex_handle v, bool *could_lock_zone) // the hint. if(!vertex_validity_check(hint, tds())) { - hint = finite_vertices_begin(); + hint_and_point = finite_vertices_begin(); continue; } // We need to make sure that while are locking the position P1 := hint->point(), 'hint' // does not get its position changed to P2 != P1. - const Weighted_point hint_point_mem = hint->point(); if(this->try_lock_point(hint_point_mem) && this->try_lock_point(wp)) { @@ -2628,7 +2636,7 @@ remove(Vertex_handle v, bool *could_lock_zone) if(!vertex_validity_check(hint, tds()) || hint->point() != hint_point_mem) { - hint = finite_vertices_begin(); + hint_and_point = finite_vertices_begin(); this->unlock_all_elements(); continue; } @@ -2639,7 +2647,7 @@ remove(Vertex_handle v, bool *could_lock_zone) { success = true; if(hv != Vertex_handle()) - hint = hv; + hint_and_point = hv; } }