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

Segmentation fault on (illegal?) type definition #21923

Closed
traktofon opened this issue May 17, 2017 · 2 comments
Closed

Segmentation fault on (illegal?) type definition #21923

traktofon opened this issue May 17, 2017 · 2 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior regression Regression in behavior compared to a previous version types and dispatch Types, subtyping and method dispatch

Comments

@traktofon
Copy link
Contributor

The following attempt at defining a recursive type (which may be illegal in the way I'm using here) immediately leads to a segmentation fault on 0.6.0-rc1 as well as on current master; it proceeds without error or segfault on 0.5.2 though.

$ julia --startup-file=no
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.0-rc1.0 (2017-05-07 00:00 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-pc-linux-gnu

julia> type Foo{T,N}; v::Vector{Foo{T}}; end

signal (11): Segmentation fault
while loading no file, in expression starting on line 0
has_free_typevars at /home/centos/buildbot/slave/package_tarball64/build/src/jltypes.c:147
has_free_typevars at /home/centos/buildbot/slave/package_tarball64/build/src/jltypes.c:159 [inlined]
jl_has_free_typevars at /home/centos/buildbot/slave/package_tarball64/build/src/jltypes.c:178
inst_type_w_ at /home/centos/buildbot/slave/package_tarball64/build/src/jltypes.c:1394
inst_all at /home/centos/buildbot/slave/package_tarball64/build/src/jltypes.c:1240 [inlined]
inst_datatype at /home/centos/buildbot/slave/package_tarball64/build/src/jltypes.c:1172
inst_type_w_ at /home/centos/buildbot/slave/package_tarball64/build/src/jltypes.c:1400
inst_type_w_ at /home/centos/buildbot/slave/package_tarball64/build/src/jltypes.c:1345
jl_instantiate_unionall at /home/centos/buildbot/slave/package_tarball64/build/src/jltypes.c:844
jl_apply_type at /home/centos/buildbot/slave/package_tarball64/build/src/jltypes.c:794
jl_call_fptr_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:337 [inlined]
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:356 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1930
do_call at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:75
eval at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:242
do_call at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:74
eval at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:242
do_call at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:74
eval at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:242
do_call at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:74
eval at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:242
eval at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:301
eval_body at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:624
jl_interpret_toplevel_thunk at /home/centos/buildbot/slave/package_tarball64/build/src/interpreter.c:692
jl_toplevel_eval_flex at /home/centos/buildbot/slave/package_tarball64/build/src/toplevel.c:590
jl_toplevel_eval_in at /home/centos/buildbot/slave/package_tarball64/build/src/builtins.c:496
eval at ./boot.jl:235
unknown function (ip: 0x7fb8a88b45af)
jl_call_fptr_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:337 [inlined]
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:356 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1930
eval_user_input at ./REPL.jl:66
unknown function (ip: 0x7fb8a892f4bf)
jl_call_fptr_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:337 [inlined]
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:356 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1930
macro expansion at ./REPL.jl:97 [inlined]
#1 at ./event.jl:73
unknown function (ip: 0x7fb8962b92af)
jl_call_fptr_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:337 [inlined]
jl_call_method_internal at /home/centos/buildbot/slave/package_tarball64/build/src/julia_internal.h:356 [inlined]
jl_apply_generic at /home/centos/buildbot/slave/package_tarball64/build/src/gf.c:1930
jl_apply at /home/centos/buildbot/slave/package_tarball64/build/src/julia.h:1422 [inlined]
start_task at /home/centos/buildbot/slave/package_tarball64/build/src/task.c:267
unknown function (ip: 0xffffffffffffffff)
Allocations: 1316512 (Pool: 1315278; Big: 1234); GC: 0
Segmentation fault

If this type definition is illegal, julia should produce an error message, but not segfault.

@fredrikekre
Copy link
Member

FWIW it works if if all arguments are specified, e.g. type Foo{T,N}; v::Vector{Foo{T, N}}; end

@martinholters martinholters added the types and dispatch Types, subtyping and method dispatch label May 17, 2017
@martinholters
Copy link
Member

This should be equivalent but errors:

julia> mutable struct Foo{T,N}; v::Vector{Foo{T,M} where M}; end
ERROR: UndefVarError: Foo not defined

This errors, too:

julia> mutable struct Foo{T,N}; v::Foo{T,M} where M; end
ERROR: UndefVarError: Foo not defined

OTOH, this should be equivalent to the latter, but works:

mutable struct Foo{T,N}; v::Foo{T}; end

@JeffBezanson JeffBezanson self-assigned this May 17, 2017
@JeffBezanson JeffBezanson added the bug Indicates an unexpected problem or unintended behavior label May 17, 2017
@JeffBezanson JeffBezanson added the regression Regression in behavior compared to a previous version label May 17, 2017
JeffBezanson added a commit that referenced this issue May 18, 2017
fix #21923, regressions in circular type definitions
tkelman pushed a commit that referenced this issue Jun 3, 2017
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 regression Regression in behavior compared to a previous version types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

4 participants