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

Constructing a FieldVector with too many elements kills Julia #342

Closed
rdeits opened this issue Nov 17, 2017 · 3 comments · Fixed by #343
Closed

Constructing a FieldVector with too many elements kills Julia #342

rdeits opened this issue Nov 17, 2017 · 3 comments · Fixed by #343

Comments

@rdeits
Copy link
Contributor

rdeits commented Nov 17, 2017

Derived from https://discourse.julialang.org/t/crash-stackoverflow-when-calling-constructor-with-too-many-inputs/7116

Here's a simple example:

julia> struct Foo{T} <: FieldVector{2, T}
         x::T
         y::T
       end

julia> Foo{Int}(1,2,3)
# Julia crashes here, presumably due to stack overflow

I believe there's an easy fix. I'll open a PR.

@rdeits
Copy link
Contributor Author

rdeits commented Nov 17, 2017

The fact that Julia crashes instead of throwing a proper StackOverflow exception is probably because I'm on a mac: JuliaLang/julia#23126 (comment)

@c42f c42f closed this as completed in #343 Nov 18, 2017
@DNF2
Copy link

DNF2 commented Nov 20, 2017

I'm still having some problems here:

julia> Pkg.status("StaticArrays")
 - StaticArrays                  0.6.6+             master

julia> using StaticArrays

julia> struct Dummy2D{T<:Real} <: FieldVector{3, T}
           x::T
           y::T
           z::T
           Dummy2D{T}(x, y) where {T} = new{T}(x, y, one(T))
       end

julia> Dummy2D(1,2,3,4)
ERROR: No precise constructor for Dummy2D found. Length of input was 4.
Stacktrace:
 [1] Dummy2D(::Int64, ::Int64, ::Int64, ::Int64) at /Users/dnf/.julia/v0.6/StaticArrays/src/convert.jl:3

julia> Dummy2D(1,2,3)
Segmentation fault: 11

@rdeits
Copy link
Contributor Author

rdeits commented Nov 21, 2017

Perhaps it's worth revisiting the question in this comment:

# Is this a good idea?? Should people just define constructors that accept tuples?

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.

2 participants