fix_segfault_when_gc_finalizing_refined_models#101
Conversation
* New PXestConnectivityRef mutable struct — explicit reference-counted wrapper for ptr_pXest_connectivity, with retain! / release! methods that free the connectivity only when the last holder is done. * Replaced the owns_ptr_pXest_connectivity::Bool and gc_ref::Any fields on OctreeDistributedDiscreteModel with a single connectivity_ref::Any field. * Updated inner and outer constructors to accept connectivity_ref instead of the old owns_ptr_pXest_connectivity, gc_ref pair. * All call sites updated: true/false, model/nothing replaced by a PXestConnectivityRef instance or model.connectivity_ref. * octree_distributed_discrete_model_free! — removed manual pXest_connectivity_destroy calls guarded by owns_ptr_pXest_connectivity; connectivity lifetime is now fully delegated to PXestConnectivityRef. AnisotropicallyAdapted3DDistributedDiscreteModels.jl Four call sites updated in the same way: connectivity_ref now threaded through AnisotropicallyAdapted3DDistributedDiscreteModel, vertically_adapt, vertically_uniformly_refine, and horizontally_adapt.
|
For reference, this PR attempts to solve a long-standing issue we have had in As far as I understand, the segmentation fault arises whenever we call The rationale behind the previous solution, based on the The solution in this PR performs a sort of manual reference counter tracking, and deallocates the shared |
OctreeDistributedDiscreteModels.jl
New PXestConnectivityRef mutable struct — explicit reference-counted wrapper for ptr_pXest_connectivity, with retain! / release! methods that free the connectivity only when the last holder is done.
Replaced the owns_ptr_pXest_connectivity::Bool and gc_ref::Any fields on OctreeDistributedDiscreteModel with a single connectivity_ref::Any field.
Updated inner and outer constructors to accept connectivity_ref instead of the old owns_ptr_pXest_connectivity, gc_ref pair.
All call sites updated: true/false, model/nothing replaced by a PXestConnectivityRef instance or model.connectivity_ref.
octree_distributed_discrete_model_free! — removed manual pXest_connectivity_destroy calls guarded by owns_ptr_pXest_connectivity; connectivity lifetime is now fully delegated to PXestConnectivityRef.
AnisotropicallyAdapted3DDistributedDiscreteModels.jl
Four call sites updated in the same way: connectivity_ref now threaded through AnisotropicallyAdapted3DDistributedDiscreteModel, vertically_adapt, vertically_uniformly_refine, and horizontally_adapt.