Skip to content

Segfault in collect in HierarchialUtilities #44501

Closed
@KristofferC

Description

@KristofferC

Somewhat of an MWE:

import HierarchicalUtils: NodeType, children

mutable struct Leaf
    n::Int64
end
struct SingletonVertex{T}
    ch::T
end

NodeType(::Type{Nothing}) = LeafNode()
NodeType(::Type{<:Tuple}) = InnerNode()
NodeType(::Type{Leaf}) = LeafNode()
NodeType(::Type{<:SingletonVertex}) = InnerNode()

children(v::Tuple) = v
children(t::SingletonVertex) = (t.ch,)

_childsort(x::Tuple) = x
_children_sorted(n) = _childsort(children(n))

l2 = Leaf(2)
n3t = SingletonVertex(l2)
ts = (n3t, nothing)

chss1 = [_children_sorted(t) for t in ts if !(isnothing(t))] # boom
signal (11): Segmentation fault: 11
in expression starting at HierarchicalUtils.jl/test/utilities.jl:25
iterate at ./tuple.jl:68 [inlined]
iterate at ./iterators.jl:470 [inlined]
iterate at ./generator.jl:44 [inlined]
grow_to! at ./array.jl:882
grow_to! at ./array.jl:864 [inlined]
collect at ./array.jl:784
unknown function (ip: 0x111a3aae9)
_jl_invoke at /Users/kristoffercarlsson/julia/src/gf.c:0 [inlined]
ijl_apply_generic at /Users/kristoffercarlsson/julia/src/gf.c:2540
...

Tested on the backports-release-1.8 branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorcompiler:codegenGeneration of LLVM IR and native code

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions