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

Another illegal instruction #21410

Closed
tkoolen opened this issue Apr 16, 2017 · 3 comments
Closed

Another illegal instruction #21410

tkoolen opened this issue Apr 16, 2017 · 3 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior inference Type inference

Comments

@tkoolen
Copy link
Contributor

tkoolen commented Apr 16, 2017

Very similar to #21243. Distilled from RigidBodyDynamics.jl:

type SpanningTree{V, E}
end

immutable TreePath{V, E}
    source::V
    source_to_lca::Vector{E}
end

function path{V, E}(src::V, target::V, tree::SpanningTree{V, E})
    TreePath(src, E[])
end

type RigidBody{T<:Number}
end

type Joint{T<:Number}
end

num_velocities(itr) = error("bad")
num_velocities{T}(p::TreePath{RigidBody{T}, Joint{T}}) = 0

type Mechanism{T<:Number}
    bodies::Vector{RigidBody{T}}
    tree::SpanningTree{RigidBody{T}, Joint{T}}

    function (::Type{Mechanism{T}}){T<:Number}(rootBody::RigidBody{T}; bla = 0)
        tree = SpanningTree{RigidBody{T}, Joint{T}}()
        new{T}([rootBody], tree)
    end
end

Mechanism{T}(rootBody::RigidBody{T}; kwargs...) = Mechanism{T}(rootBody; kwargs...)
bodies(mechanism::Mechanism) = mechanism.bodies
path(mechanism::Mechanism, from::RigidBody, to::RigidBody) = path(from, to, mechanism.tree)

function foo()
    mechanism = Mechanism(RigidBody{Float64}())
    b = first(bodies(mechanism))
    p = path(mechanism, b, b)
    nvpath = num_velocities(p)
end

foo()

With --inline=no, this results in

signal (4): Illegal instruction: 4
while loading /Users/twan/code/julia/RigidBodyDynamics/v0.6/RigidBodyDynamics/perf/runbenchmarks.jl, in expression starting on line 43
foo at /Users/twan/code/julia/RigidBodyDynamics/v0.6/RigidBodyDynamics/perf/runbenchmarks.jl:40
unknown function (ip: 0x3151a23ff)
do_call at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:75
eval at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:242
jl_interpret_toplevel_expr at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:34
jl_toplevel_eval_flex at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/toplevel.c:577
jl_parse_eval_all at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/ast.c:873
jl_load at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/toplevel.c:616 [inlined]
jl_load_ at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/toplevel.c:623
include_from_node1 at ./loading.jl:539
jlcall_include_from_node1_18834 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
include at ./sysimg.jl:14
jlcall_include_1043 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
process_options at ./client.jl:305
_start at ./client.jl:371
jlcall__start_19032 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
true_main at /Applications/Julia-0.6.app/Contents/Resources/julia/bin/julia (unknown line)
main at /Applications/Julia-0.6.app/Contents/Resources/julia/bin/julia (unknown line)
Allocations: 848930 (Pool: 847706; Big: 1224); GC: 0
Illegal instruction: 4

Perhaps more worrying, without --inline=no this results in

ERROR: LoadError: bad
Stacktrace:
 [1] foo() at /Users/twan/code/julia/RigidBodyDynamics/v0.6/RigidBodyDynamics/perf/runbenchmarks.jl:40
 [2] include_from_node1(::String) at ./loading.jl:539
 [3] include(::String) at ./sysimg.jl:14
 [4] process_options(::Base.JLOptions) at ./client.jl:305
 [5] _start() at ./client.jl:371
while loading /Users/twan/code/julia/RigidBodyDynamics/v0.6/RigidBodyDynamics/perf/runbenchmarks.jl, in expression starting on line 43

versioninfo():

Julia Version 0.6.0-pre.beta.132
Commit 52607b07f6 (2017-04-14 14:39 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin13.4.0)
  CPU: Intel(R) Core(TM) i7-3820QM CPU @ 2.70GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, ivybridge)
@martinholters
Copy link
Member

julia> a=Core.Inference.return_type(path, Tuple{Any, RigidBody{T} where T<:Number, RigidBody{T} where T<:Number})
TreePath{_,Joint{T<:Number}} where _

julia> Core.Inference.has_free_typevars(a)
true

julia> typeintersect(a, TreePath{RigidBody{T},Joint{T}} where T)
Union{}

The inferred return type of path should probably not have an unbound typevar, i.e. it's missing a where T, right?

@martinholters
Copy link
Member

Reduced repro:

julia> function foo{V, E}(::V, ::Pair{V, E})
           E
       end
foo (generic function with 1 method)

julia> code_warntype(foo, Tuple{Ref, Pair{Ref{T},Ref{T}} where T<:Number})
Variables:
  #self#::#foo
  #unused#@_2::Any
  #unused#@_3::Any

Body:
  begin 
      return $(Expr(:static_parameter, 2))
  end::Type{Ref{T<:Number}}

IIUC, this should be Type{Ref{T}} where T <: Number.

@JeffBezanson JeffBezanson added bug Indicates an unexpected problem or unintended behavior inference Type inference labels Apr 17, 2017
@JeffBezanson JeffBezanson self-assigned this Apr 17, 2017
@tkoolen
Copy link
Contributor Author

tkoolen commented Apr 17, 2017

Thank you both for your quick response!

JeffBezanson added a commit that referenced this issue Apr 18, 2017
fix #21410, need to handle static param values with free typevars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior inference Type inference
Projects
None yet
Development

No branches or pull requests

3 participants