ludvigak / FINUFFT.jl

Julia interface to the nonuniform FFT library FINUFFT
Other
33 stars 9 forks source link

Segfault: finufft in multithreaded loop on Mac OS #63

Open jkrimmer opened 2 months ago

jkrimmer commented 2 months ago

On Mac OS (arm64), I have encountered a segmentation fault with the following MWE, where the multi-threaded loop with single-threaded finufft crashes consistently. I have tried to replace the finufft library used by julia with a DUCC-FFT-based one without success. Hence, I conclude that this issue is orthogonal to #62.

using FFTW
using FINUFFT

iters = 1000
N = 1024

y = randn(ComplexF64, N)
x = randn(N)

@info "single-threaded loop, multi-threaded finufft"
for k in 1:iters
    nufft1d1(x, y, 1, 1e-8, N, nthreads=Threads.nthreads())
end
@info "multi-threaded loop, single-threaded finufft"
Threads.@threads for k in 1:iters
    nufft1d1(x, y, 1, 1e-8, N, nthreads=1)
end

Update

Even less code is required to reproduce this issue on my M3 Mac. Running the multi-threaded loop without calling finufft_makeplan before, does not crash right away. Then, I have to run the multi-threaded loop twice to reproduce the segmentation fault.

using FINUFFT
finufft_makeplan(1, [10;], 1, 1, 1e-6);
Threads.@threads for k in 1:1000
    finufft_makeplan(1, [10;], 1, 1, 1e-6);
end

julia v1.10.4 FINUFFT.jl v3.2.0 finufft_jll v2.2.0+2