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

auto_unbox Error #16165

Closed
ivirshup opened this issue May 2, 2016 · 3 comments
Closed

auto_unbox Error #16165

ivirshup opened this issue May 2, 2016 · 3 comments
Assignees
Labels
kind:bug Indicates an unexpected problem or unintended behavior

Comments

@ivirshup
Copy link
Contributor

ivirshup commented May 2, 2016

I've been getting an auto_unbox error

julia> using Combinatorics

julia> function foo()
           ts = filter(x->isa(x, DataType), map(eval, names(Base)))
           for x in ts
           end
           permutations(ts, 2)
       end
foo (generic function with 1 method)

julia> foo()
Combinatorics.Permutations{Array{Any,1}}(Any[Pair{A,B},AbstractChannel,AbstractRNG,AbstractSparseArray{Tv,Ti,N},ArgumentError,Array{T,N},AssertionError,Associative{K,V},Base64DecodePipe,Base64EncodePipe    Union,UnitRange{T<:Real},UpperTriangular{T,S<:AbstractArray{T,2}},Val{T},VersionNumber,UTF32String,WeakKeyDict{K,V},WorkerConfig,WorkerPool,Zip{I,Z<:Base.AbstractZipIterator}],2)

julia> function foo()
           ts = filter(x->isa(x, DataType), map(eval, names(Base)))
           for x in ts
           end
           permutations(ts, 2)
       end
WARNING: Method definition foo() in module Main at REPL[2]:2 overwritten at REPL[4]:2.
foo (generic function with 1 method)

julia> foo()
ERROR: auto_unbox: unable to determine argument type
 [inlined code] from /Users/isaac/.julia/v0.5/Combinatorics/src/permutations.jl:30
 in foo() at ./REPL[4]:5
 in eval(::Module, ::Any) at ./boot.jl:236

This error also occurs if I run in it a let block

let ts = filter(x->isa(x, DataType), map(eval, names(Base)))
  permutations(ts, 2)
  for x in ts
  end
end

on the second run.

It doesn't seem to matter what order the for loop or permutation occur in, and the for loop can be a comprehension and still raise the error. No error occurs if I use map instead of the loop (my current work around).

code_typed returns something different for each definition (gist, diff), but I'm not sure what I'd be looking for in those.

Possibly related, the following commands:

julia> function foo()
           ts = filter(x->isa(x, DataType), map(eval, names(Base)))
           for x in ts
           end
           permutations(ts, 2)
       end
julia> foo() # throws expected `Run Pkg.add("Combinatorics")...` error
julia> using Combinatorics
julia> foo()

give either a StackOverflowError or a bus error (gist).

@Keno
Copy link
Member

Keno commented May 3, 2016

+1 I had one too. Probably caused by recent type inference changes (@JeffBezanson @vtjnash) The source code was:

@inline function _find_module(modules, ip)
    ip = UInt(ip)
    for (mbase, h) in modules
        base = UInt(mbase)
        sz = compute_mod_size(h)::UInt
        if base <= ip <= base + sz
            return Nullable{Pair{UInt,Any}}(Pair{UInt,Any}(base,h))
        end
    end
    Nullable{Pair{UInt,Any}}()
end

fixed by renaming the argument theip or by using Tuple's instead of Pairs.
Typed code was:

@code_typed(find_module(modules,theip)) = Any[LambdaInfo for find_module
:(begin  # /home/kfischer/.julia/v0.5/Gallium/src/modules.jl, line 62:
        #temp#@_5 = ip # /home/kfischer/.julia/v0.5/Gallium/src/modules.jl, line 50:
        #temp#@_5 = (Base.box)(UInt64,#temp#@_5) # /home/kfischer/.julia/v0.5/Gallium/src/modules.jl, line 51: # dict.jl, line 842:
        i = (Base.skip_deleted)(modules,(top(getfield))(modules,:idxfloor)::Int64)::Int64 # dict.jl, line 843:
        (top(setfield!))(modules,:idxfloor,i)::Int64
        i # dict.jl, line 844:
        #temp#@_6 = i
        13:  # dict.jl, line 846:
        GenSym(5) = (Base.arraylen)((top(getfield))(modules,:vals)::Array{Any,1})::Int64 # operators.jl, line 40:
        unless (Base.box)(Base.Bool,(Base.not_int)((Base.slt_int)(GenSym(5),#temp#@_6)::Bool)) goto 62 # dict.jl, line 847:
        GenSym(7) = (Base.arrayref)((top(getfield))(modules,:keys)::Array{Gallium.RemotePtr{Void},1},#temp#@_6)::Gallium.RemotePtr{Void}
        GenSym(6) = (Base.arrayref)((top(getfield))(modules,:vals)::Array{Any,1},#temp#@_6) # operators.jl, line 520:
        (top(getfield))(Base,:Pair)::Type{Pair{A,B}} # /home/kfischer/.julia/v0.5/Gallium/src/remote.jl, line 16: # /home/kfischer/.julia/v0.5/Gallium/src/remote.jl, line 12:
        (top(getfield))(Gallium,:RemotePtr)::Type{Gallium.RemotePtr{T}}
        GenSym(8) = $(Expr(:new, Pair{Gallium.RemotePtr{Void},Any}, :($(Expr(:new, Gallium.RemotePtr{Void}, :((top(getfield))(GenSym(7),:ptr)::UInt64)))), GenSym(6)))
        GenSym(9) = (Base.skip_deleted)(modules,(Base.box)(Int64,(Base.add_int)(#temp#@_6,1)))::Int64
        GenSym(2) = GenSym(8)
        #temp#@_9 = 1
        GenSym(10) = (Base.getfield)(GenSym(2),1)
        GenSym(11) = (Base.box)(Int64,(Base.add_int)(1,1))
        mbase = GenSym(10)
        #temp#@_9 = GenSym(11)
        GenSym(12) = (Base.getfield)(GenSym(2),2)
        GenSym(13) = (Base.box)(Int64,(Base.add_int)(2,1))
        h = GenSym(12)
        #temp#@_9 = GenSym(13)
        #temp#@_6 = GenSym(9) # /home/kfischer/.julia/v0.5/Gallium/src/modules.jl, line 52:
        base = (top(getfield))(mbase,:ptr)::UInt64 # /home/kfischer/.julia/v0.5/Gallium/src/modules.jl, line 53:
        sz = (Gallium.compute_mod_size)(h)::UInt64 # /home/kfischer/.julia/v0.5/Gallium/src/modules.jl, line 54:
        unless (Base.ule_int)(base,#temp#@_5)::Bool goto 47
        #temp#@_12 = (Base.ule_int)(#temp#@_5,(Base.box)(UInt64,(Base.add_int)(base,sz)))::Bool
        goto 49
        47:
        #temp#@_12 = false
        49:
        unless #temp#@_12 goto 59 # /home/kfischer/.julia/v0.5/Gallium/src/modules.jl, line 55: # operators.jl, line 520:
        (top(getfield))(Base,:Pair)::Type{Pair{A,B}} # base.jl, line 110: # base.jl, line 110:
        (top(getfield))(Base,:Nullable)::Type{Nullable{T}}
        #temp#@_14 = $(Expr(:new, Nullable{Pair{UInt64,Any}}, false, :($(Expr(:new, Pair{UInt64,Any}, :(base), :(h))))))
        goto 68
        59:
        60:
        goto 13
        62:
        63:  # /home/kfischer/.julia/v0.5/Gallium/src/modules.jl, line 58: # base.jl, line 109:
        (top(getfield))(Base,:Nullable)::Type{Nullable{T}}
        #temp#@_14 = $(Expr(:new, Nullable{Pair{UInt64,Any}}, true))
        68:
        ret = #temp#@_14 # /home/kfischer/.julia/v0.5/Gallium/src/modules.jl, line 63:
        unless (top(getfield))(ret,:isnull)::Bool goto 77
        GenSym(14) = (Core.sizeof)(Gallium.UInt)::Int64 # int.jl, line 33:
        GenSym(15) = (top(string))("ip 0x",(Base.hex)((Base.box)(UInt64,ip),(Base.box)(Int64,(Base.mul_int)(2,GenSym(14))),false)::ASCIIString," found")::ASCIIString # error.jl, line 21:
        (Base.throw)(((top(getfield))((top(getfield))(Base.Main,:Base),:ErrorException))(GenSym(15)))::Union{}
        77:
        false
        79:  # /home/kfischer/.julia/v0.5/Gallium/src/modules.jl, line 64: # nullable.jl, line 40:
        unless (top(getfield))(ret,:isnull)::Bool goto 85
        #temp#@_15 = (Base.throw)($(Expr(:new, :((top(getfield))(Base,:NullException)::Type{NullException}))))::Union{}
        goto 87
        85:
        #temp#@_15 = (top(getfield))(ret,:value)::Pair{UInt64,Any}
        87:
        return #temp#@_15
    end::Pair{UInt64,Any})]
ERROR: LoadError: auto_unbox: unable to determine argument type

@Keno Keno added the kind:bug Indicates an unexpected problem or unintended behavior label May 3, 2016
@vtjnash
Copy link
Sponsor Member

vtjnash commented May 3, 2016

It looks like inlining (or another optimization pass) lost the TypedSlot for #temp#@_5, so codegen got confused since that variable is assigned twice with different types whereas the intrinsic calls had been expecting one strongly-typed value

@vtjnash
Copy link
Sponsor Member

vtjnash commented May 3, 2016

ok, definitely an inliner bug (specifically with the creation of temporaries). min repro:

julia> @inline f(x) = (x = UInt(x) + 1)
f (generic function with 1 method)

julia> g(x) = f(x)
g (generic function with 1 method)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants