-
Notifications
You must be signed in to change notification settings - Fork 56
Deadlock with multiple FFTW plan construction / destruction in serial and threaded runs #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Note: The issue also present on master as of now. |
Could be related to #135. |
The issue disappears when setting explicitly |
@vtjnash, any ideas? FFTW has an internal pthreads mutex lock around plan creation and destruction, but I don't see how that could deadlock Julia… Also, the interaction with |
I think I'm seeing the same issue. Here is a reduced toy case.
The last line hangs with no CPU activity coming from Julia. If, however, I replace the
then I get this segfault.
I tried to track down the issue further but I hit my limit of understanding. Hope
|
I can reproduce @EthanAnderes's first example on Julia 1.4 and FFTW 1.2.0, but I do not get a segfault in your second example (with the explicitly defined As before a Update: I also get the segfault if I start from a fresh session. |
Note: to get the seg fault I need to use a fresh session and not
on Julia v1.4.0 I don't get as much readout from the segfault:
Perhaps I should also remark that by using a generated function for |
Attempting to access FFTW inside |
@stevengj It looks like it's possibly trying to recursively hold the lock, since it's in the middle of one plan and trying to finalize a different one. I'd like to move all finalizers to a separate thread to solve this issue, but that's it's rather far away on my roadmap right now. For now, I recommend only doing trivial things in a finalizer, like appending it to a queue to be cleaned up later. |
I guess your referring to FFTW documentation that ftt plans have global mutable state? Anyway, these generated functions for caching fft plans have been working flawlessly for me |
Has anyone found a workaround other than setting |
Edit: I'm realizing now that @EthanAndres's issue seems to be different to the deadlock. @vtjnash if it's insightful at all, commenting out the finalizer here doesn't seem to change the seg fault seen with @EthanAnderes's example Line 244 in 0745fe2
|
Ok, commenting out the finalizer fixes @mfherbst's main example with threaded FFTW |
This issue should be fixed by #160. |
Great, thanks for the fix! Can't reproduce the original issue anymore on FFTW 1.2.2. I don't think we changed anything in DFTK in that respect, so the only difference seems to be that I'm running julia 1.5. |
Running the following code example causes a deadlock conjunction with Julia 1.3.1, DFTK 0.0.5 and FFTW 1.2.0. Stacktrace (after a Ctrl-C) indicates that the deadlock occurs in fftw. Notice, such behaviour is encountered both in serial and threaded runs.
Code example:
Output / Stacktrace: https://gist.github.com/mfherbst/4015ff891001597fccf66648abff1aa1
Sorry about the complicated reproducer btw ... I tried to reduce as much as I could.
The text was updated successfully, but these errors were encountered: