# Version dependent segfault using ccall

**URL:** https://discourse.julialang.org/t/version-dependent-segfault-using-ccall/41795
**Category:** General Usage
**Created:** [June 20, 2020, 10:00pm UTC](https://discourse.julialang.org/t/version-dependent-segfault-using-ccall/41795 "2020-06-20T22:00:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Matt\_Davis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matt_davis/32/7963_2.png) [@Matt\_Davis](https://discourse.julialang.org/u/Matt_Davis)
#### Post date: [June 20, 2020, 10:00pm UTC](https://discourse.julialang.org/t/version-dependent-segfault-using-ccall/41795/1 "2020-06-20T22:00:43Z")

</div>

I am running into segmentation faults and/or std::bad\_alloc errors when using the TBLIS C interface. However, the error does not appear on 1.4.x, either built from source or from binaries, but does occur on 1.5.0-beta1 and nightly builds.

Is anyone aware of any changes that may be causing this behavior? All I have been able to find is that LLVM is upgraded to 9.0.1 in 1.5+. Is there a way to build 1.4.2 with LLVM 9 to test if this is the issue?

The source code can be found here.  
[https://github.com/mdav2/TBLIS.jl](https://github.com/mdav2/TBLIS.jl)

Previously I have had similar issues ([Segfault using ccall on initialization function - #11 by yuyichao](https://discourse.julialang.org/t/segfault-using-ccall-on-initialization-function/40212/11)) but that seemed to be resolved with the helpful comments from @yuyichao.

Any help would be appreciated!

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [June 21, 2020, 12:24am UTC](https://discourse.julialang.org/t/version-dependent-segfault-using-ccall/41795/2 "2020-06-21T00:24:26Z")

</div>

I don’t think anything from LLVM is going to have anything to do with this. OTOH, incorrectly used ccall can easily cause crash in a certain version much more often then another just based on a tone of unrelated details…

---

<div class="post-metadata">

### Author: ![Matt\_Davis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matt_davis/32/7963_2.png) [@Matt\_Davis](https://discourse.julialang.org/u/Matt_Davis)
#### Post date: [June 21, 2020, 10:55pm UTC](https://discourse.julialang.org/t/version-dependent-segfault-using-ccall/41795/3 "2020-06-21T22:55:58Z")

</div>

This ended up being almost absurdly simple to fix: simply changing a structure from `struct` to `mutable struct` fixed the problem. I’m curious now why it worked at all on 1.4.2 …
