# Strange behavior when using StaticArrays.jl and Parameters.jl that is crashing Julia

**URL:** https://discourse.julialang.org/t/strange-behavior-when-using-staticarrays-jl-and-parameters-jl-that-is-crashing-julia/11654
**Category:** General Usage
**Created:** [June 13, 2018, 4:10pm UTC](https://discourse.julialang.org/t/strange-behavior-when-using-staticarrays-jl-and-parameters-jl-that-is-crashing-julia/11654 "2018-06-13T16:10:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [June 13, 2018, 4:10pm UTC](https://discourse.julialang.org/t/strange-behavior-when-using-staticarrays-jl-and-parameters-jl-that-is-crashing-julia/11654/1 "2018-06-13T16:10:51Z")

</div>

Hi guys!

I am seeing a strange behavior when using concurrently [StaticArrays.jl](https://github.com/JuliaArrays/StaticArrays.jl) and [Parameters.jl](https://github.com/mauro3/Parameters.jl) that is leading to crash. I need help because I am not sure where I should open the issue.

Look at this code:

```julia
using Parameters
using StaticArrays

@with_kw mutable struct Test{T}
    a::T = T(0)
    b::T = T(0)

    m::MVector{5,T} = zeros(MVector{5,T})
end

function conf_test(a::Number, b::Number)
    Test{Float64}(a = a,
                  b = b)
end

function gts7(testd::Test{T}) where T<:Number
    @unpack_Test testd

    m[1] = 2.0

    @pack testd = m
end

function perform_test(a::Number, b::Number)
    testd = conf_test(a,b)
    gts7(testd)
end

```

If I execute the following:

```julia-repl
julia> include("teste.jl" )
perform_test (generic function with 1 method)

julia> perform_test(1,2)

```

Julia crashes with the following log:

```julia
signal (4): Instrução ilegal
while loading no file, in expression starting on line 0
perform_test at /home/ronan.arraes/tmp/teste.jl:26
unknown function (ip: 0x7fbf53a6d88c)
jl_call_fptr_internal at /home/abuild/rpmbuild/BUILD/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/abuild/rpmbuild/BUILD/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/abuild/rpmbuild/BUILD/julia/src/gf.c:1926
do_call at /home/abuild/rpmbuild/BUILD/julia/src/interpreter.c:75
eval at /home/abuild/rpmbuild/BUILD/julia/src/interpreter.c:242
jl_interpret_toplevel_expr at /home/abuild/rpmbuild/BUILD/julia/src/interpreter.c:34
jl_toplevel_eval_flex at /home/abuild/rpmbuild/BUILD/julia/src/toplevel.c:577
jl_toplevel_eval_in at /home/abuild/rpmbuild/BUILD/julia/src/builtins.c:496
eval at ./boot.jl:235
unknown function (ip: 0x7fbfe59849ef)
jl_call_fptr_internal at /home/abuild/rpmbuild/BUILD/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/abuild/rpmbuild/BUILD/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/abuild/rpmbuild/BUILD/julia/src/gf.c:1926
eval_user_input at ./REPL.jl:66
unknown function (ip: 0x7fbfe5a0af6f)
jl_call_fptr_internal at /home/abuild/rpmbuild/BUILD/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/abuild/rpmbuild/BUILD/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/abuild/rpmbuild/BUILD/julia/src/gf.c:1926
macro expansion at ./REPL.jl:97 [inlined]
#1 at ./event.jl:73
unknown function (ip: 0x7fbf53a4a56f)
jl_call_fptr_internal at /home/abuild/rpmbuild/BUILD/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/abuild/rpmbuild/BUILD/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/abuild/rpmbuild/BUILD/julia/src/gf.c:1926
jl_apply at /home/abuild/rpmbuild/BUILD/julia/src/julia.h:1424 [inlined]
start_task at /home/abuild/rpmbuild/BUILD/julia/src/task.c:267
unknown function (ip: 0xffffffffffffffff)
Allocations: 3905426 (Pool: 3904067; Big: 1359); GC: 6
[1] 14121 illegal hardware instruction (core dumped) julia

```

On the other hand, I can do the same thing inside the `perform_test` function directly on REPL without problems:

```julia
julia> include("teste.jl" )
perform_test (generic function with 1 method)

julia> testd = conf_test(1,2)
Test{Float64}
  a: Float64 1.0
  b: Float64 2.0
  m: StaticArrays.MArray{Tuple{5},Float64,1,5}

julia> gts7(testd)
([2.0, 0.0, 0.0, 0.0, 0.0],)

```

Is it already known?

In my real code (NRLMSISE-00 model), I managed to avoid this problem by changing the `MVector` to a common `Vector`.

By the way, I am using Julia v0.6.3 and it was reproduced both on a macOS with official package and on openSUSE Linux with a server farm build package.

P.S.: “Instrução ilegal” = Illegal Instruction (or something like that).

---

<div class="post-metadata">

### Author: ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)
#### Post date: [June 13, 2018, 8:20pm UTC](https://discourse.julialang.org/t/strange-behavior-when-using-staticarrays-jl-and-parameters-jl-that-is-crashing-julia/11654/2 "2018-06-13T20:20:57Z")

</div>

I can reproduce it. (But it seems to work on julia 0.7) Strange indeed. I’ll look into it but may need a few days.

---

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [June 13, 2018, 10:14pm UTC](https://discourse.julialang.org/t/strange-behavior-when-using-staticarrays-jl-and-parameters-jl-that-is-crashing-julia/11654/3 "2018-06-13T22:14:38Z")

</div>

Thanks @mauro3

Please, let me know if you want any help or if you want some action from my side (like test or open an issue somewhere).

---

<div class="post-metadata">

### Author: ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)
#### Post date: [June 14, 2018, 12:03am UTC](https://discourse.julialang.org/t/strange-behavior-when-using-staticarrays-jl-and-parameters-jl-that-is-crashing-julia/11654/4 "2018-06-14T00:03:46Z")

</div>

@mauro3,

I don’t know if this helps, but if you add the following modification to function `gts7`, then it starts to work:

```julia
function gts7(testd::Test{T}) where T<:Number
    @unpack_Test testd

    m = copy(m)

    m[1] = 2.0

    @pack testd = m
end

```

---

<div class="post-metadata">

### Author: ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)
#### Post date: [June 14, 2018, 3:38am UTC](https://discourse.julialang.org/t/strange-behavior-when-using-staticarrays-jl-and-parameters-jl-that-is-crashing-julia/11654/5 "2018-06-14T03:38:18Z")

</div>

I suspect this is a Julia bug as Julia should not crash. To file it, I’d first try to reduce it further which I would do by manually expanding the macros of Parameters. Go for it if you want to give it a shot.
