Skip to content

segfault with user types with function fields #20523

@baggepinnen

Description

@baggepinnen

I have a segmentation fault issue, minimum working example below

abstract AbType{N}

immutable SomeType <: AbType
    f::Function
end

function SomeType()
    SomeType(v -> println(1))
end

immutable SomeOtherType <: AbType
    f::Function
end

for T in subtypes(AbType)
    (b::T)(x) = b.f(x)
end

instance = SomeType()
instance(1)

The code above segfaults at the call instance(1) (segfault message below). If the code is modified such that SomeOtherType is never defined, then the issue disappears. It also works if the definition in the for-loop is changed for the simple definition

(b::SomeType)(x) = b.f(x)
julia> versioninfo()
Julia Version 0.5.0
Commit 3c9d753* (2016-09-19 18:14 UTC)
Platform Info:
  System: Linux (x86_64-redhat-linux)
  CPU: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
  WORD_SIZE: 64
  BLAS: libopenblas (DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblasp.so.0
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)
signal (11): Segmentation fault
while loading no file, in expression starting on line 0
unknown function (ip: 0x7ff3a83b25e4)
unknown function (ip: 0x7ff3a83b1ab1)
unknown function (ip: 0x7ff3a83b0a1e)
unknown function (ip: 0x7ff3a83b0a1e)
unknown function (ip: 0x7ff3a83b0a1e)
jl_uncompress_ast at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
unknown function (ip: 0x7ff39b2d1308)
unknown function (ip: 0x7ff39b2d142b)
jl_apply_generic at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
unknown function (ip: 0x7ff39b2e88f8)
jl_apply_generic at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
unknown function (ip: 0x7ff39b2b8dae)
jl_apply_generic at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
unknown function (ip: 0x7ff3a838d8ea)
unknown function (ip: 0x7ff3a838de03)
jl_apply_generic at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
unknown function (ip: 0x7ff3a83a22fd)
unknown function (ip: 0x7ff3a83a13ed)
jl_toplevel_eval at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
unknown function (ip: 0x7ff3a839cf0b)
unknown function (ip: 0x7ff39b3df889)
unknown function (ip: 0x7ff39b3df89f)
jl_apply_generic at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
eval_user_input at ./REPL.jl:64
unknown function (ip: 0x7ff17da02b06)
jl_apply_generic at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
macro expansion at ./REPL.jl:95 [inlined]
#3 at ./event.jl:68
unknown function (ip: 0x7ff17d9fc6cf)
jl_apply_generic at /usr/bin/../lib64/libjulia.so.0.5 (unknown line)
unknown function (ip: 0x7ff3a83ab2fe)
unknown function (ip: 0xffffffffffffffff)
Allocations: 7023115 (Pool: 7021854; Big: 1261); GC: 12
Segmentation fault (core dumped)

(feel free to modify the title of this issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    types and dispatchTypes, subtyping and method dispatch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions