Skip to content

Commit 7348cfe

Browse files
committed
don't corrupt the identity of AbstractRemoteRef in their finalizers
this made it unreliable for the WeakKeyDict these are typically put in (client_refs) to have trouble finding them to cleanup the dictionary later since their hash and identity changed fixes #15923 may also fix #16091
1 parent d96de1b commit 7348cfe

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

base/multi.jl

+5-9
Original file line numberDiff line numberDiff line change
@@ -493,15 +493,13 @@ type Future <: AbstractRemoteRef
493493
v::Nullable{Any}
494494

495495
Future(w::Int, rrid::RRID) = Future(w, rrid, Nullable{Any}())
496-
Future(w::Int, rrid::RRID, v) = (r = new(w,rrid.whence,rrid.id,v); test_existing_ref(r))
496+
Future(w::Int, rrid::RRID, v) = (r = new(w,rrid.whence,rrid.id,v); return test_existing_ref(r))
497497
end
498498

499499
function finalize_future(f::Future)
500500
if f.where > 0
501501
isnull(f.v) && send_del_client(f)
502502
f.where = 0
503-
f.whence = 0
504-
f.id = 0
505503
f.v = Nullable{Any}()
506504
end
507505
f
@@ -512,7 +510,7 @@ type RemoteChannel{T<:AbstractChannel} <: AbstractRemoteRef
512510
whence::Int
513511
id::Int
514512

515-
RemoteChannel(w::Int, rrid::RRID) = (r = new(w, rrid.whence, rrid.id); test_existing_ref(r))
513+
RemoteChannel(w::Int, rrid::RRID) = (r = new(w, rrid.whence, rrid.id); return test_existing_ref(r))
516514
end
517515

518516
function test_existing_ref(r::Future)
@@ -527,25 +525,23 @@ function test_existing_ref(r::Future)
527525
end
528526
client_refs[r] = true
529527
finalizer(r, finalize_future)
530-
r
528+
return r
531529
end
532530

533531
function test_existing_ref(r::RemoteChannel)
534532
found = getkey(client_refs, r, false)
535533
!is(found,false) && (client_refs[r] == true) && return found
536534
client_refs[r] = true
537535
finalizer(r, finalize_remote_channel)
538-
r
536+
return r
539537
end
540538

541539
function finalize_remote_channel(r::RemoteChannel)
542540
if r.where > 0
543541
send_del_client(r)
544542
r.where = 0
545-
r.whence = 0
546-
r.id = 0
547543
end
548-
r
544+
return r
549545
end
550546

551547
Future(w::LocalProcess) = Future(w.id)

0 commit comments

Comments
 (0)