Skip to content

Commit df8f937

Browse files
authored
Add a safepoint in the maybe_destroy_plan spin lock (#205)
* Add a safepoint in the maybe_destroy_plan spin lock * Fix typo
1 parent e0bc05a commit df8f937

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "FFTW"
22
uuid = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
3-
version = "1.4.1"
3+
version = "1.4.2"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/fft.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,11 @@ function maybe_destroy_plan(plan::FFTWPlan)
304304
# since task switches aren't permitted in finalizers. This has suboptimal efficiency,
305305
# but we shouldn't waste too many cycles since destroying plans is quick and contention
306306
# should be rare.
307-
while !trylock(deferred_destroy_lock); end
307+
while !trylock(deferred_destroy_lock)
308+
# Need a safepoint in here because without it, this loop blocks forward progress in the GC and can deadlock
309+
# the program.
310+
GC.safepoint()
311+
end
308312
try
309313
# note: fftwlock is re-entrant, so trylock will succeed here if we
310314
# are in the task that holds the planner lock. That's okay — 

0 commit comments

Comments
 (0)