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

Segfault passing mixed types to FieldVector constructor #869

Open
ali-beep opened this issue Jan 16, 2021 · 3 comments
Open

Segfault passing mixed types to FieldVector constructor #869

ali-beep opened this issue Jan 16, 2021 · 3 comments
Labels

Comments

@ali-beep
Copy link

ali-beep commented Jan 16, 2021

As of StaticArrays v1.0.1 and julia 1.5.3 I can cause a segmentation fault like this:

using StaticArrays

struct A{T}<:FieldVector{2,T}
       x::T
       y::T
end
A(1.,2)
@c42f
Copy link
Member

c42f commented Jan 17, 2021

This is actually a stack overflow in StaticArrays default constructors. I expect you're not seeing it due to a bug in the Julia runtime where stack overflows can sometimes trigger a segfault. Like JuliaLang/julia#28577 or one of the related issues.

@c42f c42f added the bug label Jan 17, 2021
@c42f
Copy link
Member

c42f commented Jan 17, 2021

By the way, for your type you can work around it by adding a promoting constructor:

A(x,y) = A(promote(x,y)...)

@ali-beep
Copy link
Author

That is what I did; I just thought promote would have been a more reasonable default behavior than stack overflow and/or segfault. Incidentally, when I switch the order in my toy example e.g. (1,2.) I do see the stack overflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants