From b623eb5603c32b73b50c5f387584944f476484c6 Mon Sep 17 00:00:00 2001 From: Simon Byrne Date: Mon, 12 Jul 2021 21:13:59 -0700 Subject: [PATCH] use unsafe_convert instead of cconvert to ensure handles aren't GCed during ccall (#482) --- src/handle.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/handle.jl b/src/handle.jl index c202e12b9..4efe8e2f6 100644 --- a/src/handle.jl +++ b/src/handle.jl @@ -32,6 +32,9 @@ macro mpi_handle(def, mpiname=nothing, extrafields...) # allows us to pass XX objects directly into MPI_XX ccall signatures function Base.cconvert(::Type{$mpiname}, obj::$name) + obj + end + function Base.unsafe_convert(::Type{$mpiname}, obj::$name) obj.val end # allows us to pass XX objects directly into Ptr{MPI_XX} ccall signatures