Skip to content

Commit

Permalink
Merge pull request JuliaLang#12997 from JuliaLang/yyc/libuv-close
Browse files Browse the repository at this point in the history
Fix dangling pointer in libuv close callback
  • Loading branch information
vtjnash committed Sep 8, 2015
2 parents 5edd47c + 2da17b0 commit 09e9655
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
1 change: 0 additions & 1 deletion base/poll.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ end
function close(t::Union{FileMonitor, PollingFileWatcher})
if t.handle != C_NULL
ccall(:jl_close_uv, Void, (Ptr{Void},), t.handle)
t.handle = C_NULL
end
end

Expand Down
35 changes: 35 additions & 0 deletions test/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -887,3 +887,38 @@ let n = tempname()
close(io); close(w)
rm(n)
end

#issue #12992
function test_12992()
pfw = PollingFileWatcher(@__FILE__, 0.01)
close(pfw)
pfw = PollingFileWatcher(@__FILE__, 0.01)
close(pfw)
pfw = PollingFileWatcher(@__FILE__, 0.01)
close(pfw)
gc()
gc()
end

# Make sure multiple close is fine
function test2_12992()
pfw = PollingFileWatcher(@__FILE__, 0.01)
close(pfw)
close(pfw)
pfw = PollingFileWatcher(@__FILE__, 0.01)
close(pfw)
close(pfw)
pfw = PollingFileWatcher(@__FILE__, 0.01)
close(pfw)
close(pfw)
gc()
gc()
end

test_12992()
test_12992()
test_12992()

test2_12992()
test2_12992()
test2_12992()

0 comments on commit 09e9655

Please sign in to comment.