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

Can't index into a Dict{Int,Type} after running BaseBenchmarks.loadall!() #21028

Closed
pabloferz opened this issue Mar 14, 2017 · 13 comments
Closed
Labels
domain:types and dispatch Types, subtyping and method dispatch kind:bug Indicates an unexpected problem or unintended behavior

Comments

@pabloferz
Copy link
Contributor

pabloferz commented Mar 14, 2017

In the last couple of days something broke the following

d = Dict{Int,Type}()
d[1] = Int

this in turns breaks JLD and BenchmarkTools

@yuyichao
Copy link
Contributor

What's your version? 0.6.0-pre.alpha.142 64409a0 works fine for me.

@pabloferz
Copy link
Contributor Author

Ok, seems I made a mistake, seems that is #20720 which would break this (weirdly enough that doesn't touches inference).

@tkelman
Copy link
Contributor

tkelman commented Mar 14, 2017

be sure to add a test for that?

@pabloferz
Copy link
Contributor Author

pabloferz commented Mar 15, 2017

On 1820efa, if I do

d = Dict{Int,Type}()
d[1] = Int

everything works, but if do (on a fresh REPL)

using BaseBenchmarks
BaseBenchmarks.loadall!() # this fails setindex!-ing a Dict{Int,Type}
d = Dict{Int,Type}()
d[1] = Int

the last one fails here

@pabloferz pabloferz changed the title Can't index into a Dict{Int,Type} Can't index into a Dict{Int,Type} after running BaseBenchmarks.loadall!() Mar 15, 2017
@pabloferz pabloferz reopened this Mar 15, 2017
@JeffBezanson
Copy link
Sponsor Member

Could you post the error, or whatever output there is?

@pabloferz
Copy link
Contributor Author

julia> using BaseBenchmarks

julia> BaseBenchmarks.loadall!()
loading group "string"...done (took 0.588424233 seconds)
loading group "linalg"...WARNING: filter(flt, itr) is deprecated, use Iterators.filter(flt, itr) instead.
Stacktrace:
 [1] depwarn(::String, ::Symbol) at ./deprecated.jl:64
 [2] filter(::Function, ::NTuple{7,UnionAll}) at ./deprecated.jl:51
 [3] include_from_node1(::String) at ./loading.jl:539
 [4] include(::String) at ./sysimg.jl:14
 [5] #load!#2(::Bool, ::Function, ::BenchmarkTools.BenchmarkGroup, ::String) at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/BaseBenchmarks.jl:39
 [6] (::BaseBenchmarks.#kw##load!)(::Array{Any,1}, ::BaseBenchmarks.#load!, ::BenchmarkTools.BenchmarkGroup, ::String) at ./<missing>:0
 [7] #loadall!#6(::Bool, ::Bool, ::Function, ::BenchmarkTools.BenchmarkGroup) at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/BaseBenchmarks.jl:53
 [8] #loadall!#5(::Array{Any,1}, ::Function) at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/BaseBenchmarks.jl:48
 [9] loadall!() at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/BaseBenchmarks.jl:48
 [10] eval(::Module, ::Any) at ./boot.jl:235
 [11] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
 [12] macro expansion at ./REPL.jl:97 [inlined]
 [13] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/linalg/LinAlgBenchmarks.jl, in expression starting on line 16
done (took 11.765382401 seconds)
loading group "parallel"...done (took 0.104855176 seconds)
loading group "tuple"...done (took 2.974122399 seconds)
loading group "dates"...done (took 2.038936224 seconds)
loading group "micro"...done (took 0.517584081 seconds)
loading group "io"...done (took 0.570476438 seconds)
loading group "scalar"...done (took 29.934090327 seconds)
loading group "sparse"...done (took 5.464621647 seconds)
loading group "broadcast"...done (took 1.510048523 seconds)
loading group "simd"...done (took 2.550524409 seconds)
loading group "problem"...
WARNING: deprecated syntax "typealias IMDBGraph Dict{UTF8String,IMDBNode}" at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/problem/IMDBGraphs.jl:15.
Use "const IMDBGraph = Dict{UTF8String,IMDBNode}" instead.

WARNING: deprecated syntax "abstract Scene" at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/problem/Raytracer.jl:41.
Use "abstract type Scene end" instead.
done (took 1.996170801 seconds)
loading group "array"...
WARNING: deprecated syntax "abstract MyArray{T,N}<:AbstractArray{T,N}" at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/array/sumindex.jl:199.
Use "abstract type MyArray{T,N}<:AbstractArray{T,N} end" instead.
WARNING: Base.linearindexing is deprecated, use Base.IndexStyle instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/array/sumindex.jl:263
WARNING: Partial linear indexing is deprecated. Use `reshape(A, Val{2})` to make the dimensionality of the array match the number of indices.
Stacktrace:
 [1] partial_linear_indexing_warning_lookup(::Int64) at ./deprecated.jl:1050
 [2] checkbounds_linear_indices at ./abstractarray.jl:402 [inlined]
 [3] checkbounds_indices at ./abstractarray.jl:395 [inlined]
 [4] checkbounds_indices at ./abstractarray.jl:381 [inlined]
 [5] checkbounds at ./abstractarray.jl:334 [inlined]
 [6] checkbounds(::SubArray{Int32,3,Array{Int32,3},Tuple{Base.Slice{Base.OneTo{Int64}},Base.Slice{Base.OneTo{Int64}},Base.Slice{Base.OneTo{Int64}}},true}, ::Base.Slice{Base.OneTo{Int64}}, ::UnitRange{Int64}) at ./abstractarray.jl:354
 [7] view(::SubArray{Int32,3,Array{Int32,3},Tuple{Base.Slice{Base.OneTo{Int64}},Base.Slice{Base.OneTo{Int64}},Base.Slice{Base.OneTo{Int64}}},true}, ::Colon, ::Vararg{Any,N} where N) at ./subarray.jl:113
 [8] makearrays(::Type{Int32}, ::Int64, ::Int64) at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/array/sumindex.jl:298
 [9] include_from_node1(::String) at ./loading.jl:539
 [10] include(::String) at ./sysimg.jl:14
 [11] #load!#2(::Bool, ::Function, ::BenchmarkTools.BenchmarkGroup, ::String) at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/BaseBenchmarks.jl:39
 [12] (::BaseBenchmarks.#kw##load!)(::Array{Any,1}, ::BaseBenchmarks.#load!, ::BenchmarkTools.BenchmarkGroup, ::String) at ./<missing>:0
 [13] #loadall!#6(::Bool, ::Bool, ::Function, ::BenchmarkTools.BenchmarkGroup) at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/BaseBenchmarks.jl:53
 [14] #loadall!#5(::Array{Any,1}, ::Function) at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/BaseBenchmarks.jl:48
 [15] loadall!() at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/BaseBenchmarks.jl:48
 [16] eval(::Module, ::Any) at ./boot.jl:235
 [17] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
 [18] macro expansion at ./REPL.jl:97 [inlined]
 [19] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/array/ArrayBenchmarks.jl, in expression starting on line 47
done (took 30.402400938 seconds)
loading group "misc"...done (took 1.779329819 seconds)
loading group "sort"...done (took 3.917152019 seconds)
loading group "nullable"...WARNING: Base.linearindexing is deprecated, use Base.IndexStyle instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:56
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
WARNING: Base.LinearFast is deprecated, use Base.IndexLinear instead.
  likely near /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/nullable/NullableBenchmarks.jl:85
done (took 7.701400756 seconds)
loading group "shootout"...
WARNING: deprecated syntax "abstract BTree" at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/shootout/binary_trees.jl:8.
Use "abstract type BTree end" instead.
done (took 0.947569795 seconds)
ERROR: MethodError: First argument to `convert` must be a Type, got V
Stacktrace:
 [1] setindex!(::Dict{Int64,Type}, ::Type, ::Int64) at ./dict.jl:420
 [2] setindex!(::Dict{Int64,Type}, ::Type{T} where T, ::UInt64) at ./dict.jl:416
 [3] jldatatype(::JLD.JldFile, ::HDF5.HDF5Datatype) at /home/pabloferz/.julia/v0.6/JLD/src/jld_types.jl:754
 [4] read(::JLD.JldDataset) at /home/pabloferz/.julia/v0.6/JLD/src/JLD.jl:385
 [5] read(::JLD.JldFile, ::String) at /home/pabloferz/.julia/v0.6/JLD/src/JLD.jl:361
 [6] (::BaseBenchmarks.##7#8{BenchmarkTools.BenchmarkGroup})(::JLD.JldFile) at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/BaseBenchmarks.jl:59
 [7] #jldopen#11(::Array{Any,1}, ::Function, ::BaseBenchmarks.##7#8{BenchmarkTools.BenchmarkGroup}, ::String, ::Vararg{String,N} where N) at /home/pabloferz/.julia/v0.6/JLD/src/JLD.jl:260
 [8] #loadall!#6(::Bool, ::Bool, ::Function, ::BenchmarkTools.BenchmarkGroup) at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/BaseBenchmarks.jl:57
 [9] #loadall!#5(::Array{Any,1}, ::Function) at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/BaseBenchmarks.jl:48
 [10] loadall!() at /home/pabloferz/.julia/v0.6/BaseBenchmarks/src/BaseBenchmarks.jl:48

pabloferz referenced this issue Mar 15, 2017
Use proper alignment when copying data to a variable.
@pabloferz
Copy link
Contributor Author

pabloferz commented Mar 15, 2017

@nanosoldier failed in the last daily run for the same reason. X-ref: 1820efa

@pabloferz
Copy link
Contributor Author

Also, @nanosoldier was working yestarday, so it seems this started happening with 64409a0

@pabloferz
Copy link
Contributor Author

So far I have found that JLD creates julia types from strings using the function JLD.julia_type and then stores them on a field jlh5type of an object of type JldFile which is a Dict{Int,Type}.

It doesn't alway causes the problem and the only way I have found so far to trigger it is by calling

using BaseBenchmarks
BaseBenchmarks.load!("shootout")

@jrevels
Copy link
Member

jrevels commented Mar 15, 2017

Just saw that this issue existed, so I'll paste my previous comment here:

Here's the stacktrace in the logs, which points to here. From the error message, it seems like V isn't getting "bound" to the correct type at runtime, and instead is considered a TypeVar when it's used in the method body. For example, here's how to recreate that error message:

julia> convert(TypeVar(:V), 1)
ERROR: MethodError: First argument to `convert` must be a Type, got V

AFIAK, V in JLD's case should be bound to a value of type Type, not TypeVar. Is this a bug in type inference?

@pabloferz
Copy link
Contributor Author

Here's a simplified repro

julia> using BaseBenchmarks
julia> file = JLD.jldopen(BaseBenchmarks.PARAMS_PATH, "r")
julia> obj = file["shootout"]
julia> par = HDF5.file(obj)
julia> T = JLD.julia_type("BenchmarkTools.BenchmarkGroup")
julia> dtype = HDF5.datatype(obj.plain)
julia> addr = HDF5.objinfo(dtype).addr
julia> par.h5jltype[addr] = T
ERROR: MethodError: First argument to `convert` must be a Type, got V
Stacktrace:
 [1] setindex!(::Dict{Int64,Type}, ::Type, ::Int64) at ./dict.jl:420
 [2] setindex!(::Dict{Int64,Type}, ::Type{T} where T, ::UInt64) at ./dict.jl:416

@pabloferz
Copy link
Contributor Author

Even smaller

julia> using BaseBenchmarks
julia> file = JLD.jldopen(BaseBenchmarks.PARAMS_PATH, "r")
julia> par = HDF5.file(file["shootout"])
julia> par.h5jltype[1] = Int
ERROR: MethodError: First argument to `convert` must be a Type, got V
Stacktrace:
 [1] setindex!(::Dict{Int64,Type}, ::Type, ::Int64) at ./dict.jl:420

@JeffBezanson
Copy link
Sponsor Member

I have a fix for this.

@JeffBezanson JeffBezanson added kind:bug Indicates an unexpected problem or unintended behavior domain:types and dispatch Types, subtyping and method dispatch labels Mar 16, 2017
JeffBezanson added a commit that referenced this issue Mar 16, 2017
fix #21028, static parameter value incorrectly set to typevar
ajkeller34 pushed a commit to ajkeller34/julia that referenced this issue Mar 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:types and dispatch Types, subtyping and method dispatch kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

5 participants