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

A segfault with member functions #493

Closed
JanisErdmanis opened this issue Sep 8, 2018 · 3 comments
Closed

A segfault with member functions #493

JanisErdmanis opened this issue Sep 8, 2018 · 3 comments

Comments

@JanisErdmanis
Copy link

JanisErdmanis commented Sep 8, 2018

Hello. When I tried to execute example notebook of RegionTrees.jl package I found a segfault on my system (Ubuntu 18.04). Purifying the crashing code I came up with this one:

SEGFAULT = true
using StaticArrays

struct TwosArray{N, T, L} <: StaticArray{NTuple{N, 2}, T, N}
    data::NTuple{L, T}
end
Base.getindex(b::TwosArray, i::Int) = b.data[i]

struct SignedDistanceRefinery{F <: Function} # <: AbstractRefinery 
    signed_distance_func::F
end

function refine_data(refinery::SignedDistanceRefinery, v) 
    refinery.signed_distance_func.(v)
end

signed_distance(x) = sqrt(sum(x.^2))
refinery = SignedDistanceRefinery(signed_distance)

vp = TwosArray{1,SArray{Tuple{2},Float64,1,2},2}((SVector(1.,2.),SVector(3.,1.)))

!SEGFAULT || refinery.signed_distance_func.(vp)
refine_data(refinery,vp)

Interestingly to cause a segfault both last two lines need to be present which also commute with themselves.

@andyferris
Copy link
Member

Any ideas what is going wrong here?

Interestingly to cause a segfault both last two lines need to be present which also commute with themselves.

Is this likely to be a Julia bug, then?

@schmrlng
Copy link
Contributor

Potentially related to #482 and JuliaLang/julia#28981 (the core issue there seems to be nested broadcasting which appears here too).

@c42f
Copy link
Member

c42f commented Sep 10, 2018

Hmm. Seems Jameson has suggested at JuliaLang/julia#28981 (comment) that we can't be using return_type the way we do.

andyferris pushed a commit that referenced this issue Sep 20, 2018
Solve various inference issues. Replaces #495 and #330.
Closes #493.

Note: the eltype of empty arrays may become `Union{}` in
`map`, `broadcast`, and `mapreduce(...; dims = Val{N})`.
andyferris pushed a commit that referenced this issue Sep 20, 2018
Solve various inference issues. Replaces #495 and #330.
Closes #493.

Note: the eltype of empty arrays may become `Union{}` in
`map`, `broadcast`, and `mapreduce(...; dims = Val{N})`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants