Skip to content
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

empty!(::WeakKeyDict) throws error #18204

Closed
dbeach24 opened this issue Aug 23, 2016 · 6 comments
Closed

empty!(::WeakKeyDict) throws error #18204

dbeach24 opened this issue Aug 23, 2016 · 6 comments

Comments

@dbeach24
Copy link
Contributor

Demonstration:

julia> versioninfo()
Julia Version 0.6.0-dev.374
Commit 7199111* (2016-08-23 15:07 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)

julia> x = WeakKeyDict{Int,Int}()
WeakKeyDict{Int64,Int64} with 0 entries

julia> empty!(x)
ERROR: MethodError: no method matching lock(::Base.##378#379{WeakKeyDict{Int64,Int64}})
Closest candidates are:
  lock(::Any, ::WeakKeyDict{K,V}) at weakkeydict.jl:21
  lock(::Any, ::Any) at lock.jl:99
  lock(::Base.Threads.Mutex) at locks.jl:206
  ...
 in empty!(::WeakKeyDict{Int64,Int64}) at ./weakkeydict.jl:48

I found this while reading the source (line 49 of base/weakkeydict.jl):

empty!(wkh::WeakKeyDict) = (lock(() -> empty!(wkh.ht)); wkh)

Probably was meant to be:

empty!(wkh::WeakKeyDict) = lock(() -> empty!(wkh.ht), wkh)
@dbeach24 dbeach24 changed the title empty!(::WeakKeyDict) throws error empty!(::WeakKeyDict) throws error Aug 23, 2016
@tkelman tkelman added the needs tests Unit tests are required for this change label Aug 23, 2016
@mauro3
Copy link
Contributor

mauro3 commented Dec 8, 2016

On 0.6 this seems to work now. On 0.5, this actually segfaults when there is an non-empty dict:

julia> x = WeakKeyDict()
WeakKeyDict{Any,Any} with 0 entries

julia> x[BigFloat(1)] = 1
1

julia> empty!(x)

signal (11): Segmentation fault
while loading no file, in expression starting on line 0
unknown function (ip: 0x7fbe65b5dd0e)
decompose at ./hashing2.jl:140
hash at ./hashing2.jl:32
hashindex at ./dict.jl:441 [inlined]
ht_keyindex at ./dict.jl:536
delete! at ./dict.jl:736 [inlined]
#374 at ./weakkeydict.jl:49
lock at ./lock.jl:101
#356 at ./weakkeydict.jl:15
jl_call_method_internal at /home/mauro/julia/julia-0.5/src/julia_internal.h:189 [inlined]
...

Worth a back-port? (Not for me, I don't use it)

@kshyatt
Copy link
Contributor

kshyatt commented Dec 8, 2016

I think I fixed this in #19485 ? Should I open a PR against release-0.5 to fix the bug there, @tkelman ?

@kshyatt kshyatt closed this as completed Dec 8, 2016
@tkelman
Copy link
Contributor

tkelman commented Dec 8, 2016

It's just a matter of backporting that PR but without using a testset, right?

@kshyatt
Copy link
Contributor

kshyatt commented Dec 8, 2016

I think so.

@tkelman tkelman removed the needs tests Unit tests are required for this change label Dec 8, 2016
@tkelman
Copy link
Contributor

tkelman commented Dec 8, 2016

Unless you plan on running pkgeval on backports, I'll get it.

@kshyatt
Copy link
Contributor

kshyatt commented Dec 8, 2016

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants