-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Segfault when reinterpreting in a for loop #20847
Comments
It looks similar to #17003 because putting the loop in a function, llvm says (note the trap):
|
This isn't #17003 but is also an inference error. The loop can be replaced with a function and is just a way to trigger type inference. julia> function segfaultfunction{N, T}(A::Vector{NTuple{N, T}})
B = reinterpret(T, A, (N, length(A)))
return nothing
end
segfaultfunction (generic function with 1 method)
julia> code_warntype(segfaultfunction, Tuple{Any})
Variables:
#self#::#segfaultfunction
A::Array{Tuple{Vararg{T,N}},1} where T where N
B::Any
Body:
begin
B::Any = (Main.reinterpret)($(Expr(:static_parameter, 2)), A::Array{Tuple{Vararg{T,N}},1} where T where N, (Core.tuple)($(Expr(:static_parameter, 1)), (Base.arraylen)(A::Array{Tuple{Vararg{T,N}},1} where T where N)::Int64)::Tuple{Any,Int64})::Union{} # line 3:
end::Union{} |
The problem is in type-intersection-env: the static-parameter 2 value is not correctly expressed, leading to an ambiguity about whether it is actually
This leads type-inference to conclude that it should replace the call |
Still crashes with newest master |
Found this in https://github.com/KristofferC/JuAFEM.jl/pull/123 on all nightly build bots. Reduced to the following MRE:
Pasting this in the REPL gives:
The following functions also segfaults:
but this one (without any paremeters
N
orT
) worksfor
-loop is there.tuplevec
is defined inside thefor
-loop it doesn't segfault (same mechanism as if thefor
-loop wouldn't be there I guess)reinterpret
inside the function is successful, e.g.@show B
before returning worksPerhaps related to #17003 but the examples in this issue all work on 0.5 so I figured this might be another issue.
The text was updated successfully, but these errors were encountered: