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

Segfault on invalid parametric code #23630

Closed
turtleslow opened this issue Sep 8, 2017 · 5 comments
Closed

Segfault on invalid parametric code #23630

turtleslow opened this issue Sep 8, 2017 · 5 comments
Labels
bug Indicates an unexpected problem or unintended behavior types and dispatch Types, subtyping and method dispatch

Comments

@turtleslow
Copy link

The following invalid code results in a segfault for me: Set{Array{T}}() where {T<:Float64}

Full details:

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.0 (2017-06-19 13:05 UTC)
 _/ |\__'_|_|_|\__'_|  |  
|__/                   |  x86_64-suse-linux

julia> versioninfo()
Julia Version 0.6.0
Commit 903644385b* (2017-06-19 13:05 UTC)
Platform Info:
  OS: Linux (x86_64-suse-linux)
  CPU: Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
  WORD_SIZE: 64
  BLAS: libopenblas (DYNAMIC_ARCH Haswell)
  LAPACK: libopenblas_openmp.so.0
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, haswell)

julia> Set{Array{T}}() where {T<:Float64}

signal (11): Segmentation fault
while loading no file, in expression starting on line 0
jl_new_structv at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/datatype.c:679
Type at ./dict.jl:104
jl_call_fptr_internal at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/gf.c:1933
Type at ./set.jl:6
jl_call_fptr_internal at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/gf.c:1933
do_call at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/interpreter.c:75
eval at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/interpreter.c:242
do_call at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/interpreter.c:74
eval at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/interpreter.c:242
eval_body at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/interpreter.c:539
jl_interpret_toplevel_thunk at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/interpreter.c:692
jl_toplevel_eval_flex at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/toplevel.c:592
jl_toplevel_eval_in at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/builtins.c:496
eval at ./boot.jl:235
unknown function (ip: 0x7f7dad6574ff)
jl_call_fptr_internal at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/gf.c:1933
eval_user_input at ./REPL.jl:66
unknown function (ip: 0x7f7dad6ca0ef)
jl_call_fptr_internal at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/gf.c:1933
macro expansion at ./REPL.jl:97 [inlined]
#1 at ./event.jl:73
unknown function (ip: 0x7f7d90e3155f)
jl_call_fptr_internal at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/gf.c:1933
jl_apply at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/julia.h:1424 [inlined]
start_task at /home/abuild/rpmbuild/BUILD/julia-0.6.0/src/task.c:267
unknown function (ip: 0xffffffffffffffff)
Allocations: 3884938 (Pool: 3883572; Big: 1366); GC: 6
Segmentation fault (core dumped)

@quinnj
Copy link
Member

quinnj commented Sep 8, 2017

Looks like the type it's trying to construct is

(lldb) expr jl_(type)
Base.Dict{Array{T<:Float64, N} where N, Void}

And in particular, we have

(lldb) p ((jl_datatype_t*)type)->layout
(const jl_datatype_layout_t *) $3 = 0x0000000000000000

which is problematic for jl_datatype_nfields trying to get nfields from a null layout.

@ararslan
Copy link
Member

ararslan commented Sep 8, 2017

The same happens on current master. Seems like this should just be a syntax error, since the where is misplaced.

@ararslan ararslan added the bug Indicates an unexpected problem or unintended behavior label Sep 8, 2017
@JeffBezanson
Copy link
Member

This is causing a type with free variables to get passed to a constructor. Ideally the set constructor method should not match in this case.

@JeffBezanson JeffBezanson added the types and dispatch Types, subtyping and method dispatch label Sep 8, 2017
@JeffBezanson
Copy link
Member

This has now gotten harder to reproduce (since the free typevar causes an UndefVarError), but this manages to do it:

struct Bar{T} 
    (T::Type{Bar{S}})() where S = new{T.parameters[1]}()
end

Bar{T}() where T

@JeffBezanson
Copy link
Member

Duplicate of #29145, and fixed.

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 types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

4 participants