JuliaMath / FFTW.jl

Julia bindings to the FFTW library for fast Fourier transforms
https://juliamath.github.io/FFTW.jl/stable
MIT License
269 stars 54 forks source link

Crash on Windows when explicitly setting number of threads #306

Open ludvigak opened 3 weeks ago

ludvigak commented 3 weeks ago

Related to the FINUFFT.jl issue https://github.com/ludvigak/FINUFFT.jl/issues/61 we have boiled down that the following code causes a crash running on Windows with Julia v1.10.4 and FFTW v1.8.0, but only when explicitly setting the thread count in julia using --threads.

using FFTW
FFTW.set_num_threads(6)
data = rand(ComplexF32, 64)
for i in 1:10000
    @show i
    fft(data)
end

e.g. running julia --threads=8 fftwcrash.jl gives the following output, although the number of iterations before the crash varies from run to run

[...]
i = 967

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x63975556 -- .text at C:\Users\me\.julia\artifacts\b7dd1809d0626eac3bf6f97ba8ccfbb6cc63c509\bin\libfftw3f-3.dll (unknown line)
in expression starting at C:\Users\me\fftwcrash.jl:4
.text at C:\Users\me\.julia\artifacts\b7dd1809d0626eac3bf6f97ba8ccfbb6cc63c509\bin\libfftw3f-3.dll (unknown line)
#2 at C:\Users\me\.julia\packages\FFTW\6nZei\src\providers.jl:58
unknown function (ip: 0000018d5b11139b)
jl_apply at C:/workdir/src\julia.h:1982 [inlined]
start_task at C:/workdir/src\task.c:1238
Allocations: 2908 (Pool: 2900; Big: 8); GC: 0

Results do vary with other choices of array length and arguments to set_num_threads and --threads, but the above combination consistently crashes.

ludvigak commented 3 weeks ago

This might be a duplicate of https://github.com/JuliaMath/FFTW.jl/issues/200 and https://github.com/JuliaMath/FFTW.jl/issues/275

ahbarnett commented 3 weeks ago

Tested your example on ubuntu 22.04 linux (Ryzen 2, 5700U), FFTW v1.8.0 (FFTW.version=3.3.10), Julia 1.10.0, and no crash, FYI.