-
-
Notifications
You must be signed in to change notification settings - Fork 83
Deadlock during memory free #685
Comments
In reference to #691, changing julia> l1=Threads.SpinLock();
julia> l2=ReentrantLock();
julia> @btime Base.@lock $l1 begin end
20.569 ns (0 allocations: 0 bytes)
julia> @btime Base.@lock $l2 begin end
37.242 ns (0 allocations: 0 bytes) Perhaps changing all/some of the locks in CuArrays to a |
No, the code does not support that. I'll have a look. |
Ah I thought they'd be interchangeable. Could you elaborate why the code wouldn't support a |
A reentrant lock can be taken by the same task. But in this case, we're protecting against concurrent access of datastructures that are used in regular code as well as from finalizers. So while we're modifying the map and have the lock, a GC run could trigger our finalizer that, potentially on the same task, will be able to acquire the lock and start modifying the same datastructure too. |
I see. So there's no guarantee that finalizes are run in a separate task and swapping |
We maintain a mapping of pointers to memory blocks,
allocated
, protected by a (non-reentrant) spinlock,allocated_lock
, but when we take that lock setting a value in the dict can trigger a GC collection which might deadlock when freeing other GPU memory:The text was updated successfully, but these errors were encountered: