{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/18204","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/18204/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/18204/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/18204/events","html_url":"https://github.com/JuliaLang/julia/issues/18204","id":172745824,"number":18204,"title":"empty!(::WeakKeyDict) throws error","user":{"login":"dbeach24","id":11604259,"avatar_url":"https://avatars.githubusercontent.com/u/11604259?v=3","gravatar_id":"","url":"https://api.github.com/users/dbeach24","html_url":"https://github.com/dbeach24","followers_url":"https://api.github.com/users/dbeach24/followers","following_url":"https://api.github.com/users/dbeach24/following{/other_user}","gists_url":"https://api.github.com/users/dbeach24/gists{/gist_id}","starred_url":"https://api.github.com/users/dbeach24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbeach24/subscriptions","organizations_url":"https://api.github.com/users/dbeach24/orgs","repos_url":"https://api.github.com/users/dbeach24/repos","events_url":"https://api.github.com/users/dbeach24/events{/privacy}","received_events_url":"https://api.github.com/users/dbeach24/received_events","type":"User","site_admin":false},"labels":[{"id":294535960,"url":"https://api.github.com/repos/JuliaLang/julia/labels/needs%20tests","name":"needs tests","color":"5319e7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-23T16:28:23Z","updated_at":"2016-12-08T08:13:12Z","closed_at":null,"body":"Demonstration:\n\n``` julia\n\njulia> versioninfo()\nJulia Version 0.6.0-dev.374\nCommit 7199111* (2016-08-23 15:07 UTC)\nPlatform Info:\n  System: Darwin (x86_64-apple-darwin14.5.0)\n  CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz\n  WORD_SIZE: 64\n  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)\n  LAPACK: libopenblas64_\n  LIBM: libopenlibm\n  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)\n\njulia> x = WeakKeyDict{Int,Int}()\nWeakKeyDict{Int64,Int64} with 0 entries\n\njulia> empty!(x)\nERROR: MethodError: no method matching lock(::Base.##378#379{WeakKeyDict{Int64,Int64}})\nClosest candidates are:\n  lock(::Any, ::WeakKeyDict{K,V}) at weakkeydict.jl:21\n  lock(::Any, ::Any) at lock.jl:99\n  lock(::Base.Threads.Mutex) at locks.jl:206\n  ...\n in empty!(::WeakKeyDict{Int64,Int64}) at ./weakkeydict.jl:48\n```\n\nI found this while reading the source (line 49 of base/weakkeydict.jl):\n\n``` julia\nempty!(wkh::WeakKeyDict) = (lock(() -> empty!(wkh.ht)); wkh)\n```\n\nProbably was meant to be:\n\n``` julia\nempty!(wkh::WeakKeyDict) = lock(() -> empty!(wkh.ht), wkh)\n```\n"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/265679348","html_url":"https://github.com/JuliaLang/julia/issues/18204#issuecomment-265679348","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/18204","id":265679348,"user":{"login":"mauro3","id":4098145,"avatar_url":"https://avatars.githubusercontent.com/u/4098145?v=3","gravatar_id":"","url":"https://api.github.com/users/mauro3","html_url":"https://github.com/mauro3","followers_url":"https://api.github.com/users/mauro3/followers","following_url":"https://api.github.com/users/mauro3/following{/other_user}","gists_url":"https://api.github.com/users/mauro3/gists{/gist_id}","starred_url":"https://api.github.com/users/mauro3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mauro3/subscriptions","organizations_url":"https://api.github.com/users/mauro3/orgs","repos_url":"https://api.github.com/users/mauro3/repos","events_url":"https://api.github.com/users/mauro3/events{/privacy}","received_events_url":"https://api.github.com/users/mauro3/received_events","type":"User","site_admin":false},"created_at":"2016-12-08T08:13:11Z","updated_at":"2016-12-08T08:13:11Z","body":"On 0.6 this seems to work now.  On 0.5, this actually segfaults when there is an non-empty dict:\r\n```julia\r\njulia> x = WeakKeyDict()\r\nWeakKeyDict{Any,Any} with 0 entries\r\n\r\njulia> x[BigFloat(1)] = 1\r\n1\r\n\r\njulia> empty!(x)\r\n\r\nsignal (11): Segmentation fault\r\nwhile loading no file, in expression starting on line 0\r\nunknown function (ip: 0x7fbe65b5dd0e)\r\ndecompose at ./hashing2.jl:140\r\nhash at ./hashing2.jl:32\r\nhashindex at ./dict.jl:441 [inlined]\r\nht_keyindex at ./dict.jl:536\r\ndelete! at ./dict.jl:736 [inlined]\r\n#374 at ./weakkeydict.jl:49\r\nlock at ./lock.jl:101\r\n#356 at ./weakkeydict.jl:15\r\njl_call_method_internal at /home/mauro/julia/julia-0.5/src/julia_internal.h:189 [inlined]\r\n...\r\n```\r\nWorth a back-port? (Not for me, I don't use it)"}}
{"actor":{"display_login":"mauro3"}}