# Crash: illegal instruction 4, StackOverflowError, or freeze

**URL:** https://discourse.julialang.org/t/crash-illegal-instruction-4-stackoverflowerror-or-freeze/116754
**Category:** General Usage
**Tags:** stackoverflow, crash, illegal-instruction
**Created:** [July 8, 2024, 7:41am UTC](https://discourse.julialang.org/t/crash-illegal-instruction-4-stackoverflowerror-or-freeze/116754 "2024-07-08T07:41:43Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)
#### Post date: [July 8, 2024, 7:41am UTC](https://discourse.julialang.org/t/crash-illegal-instruction-4-stackoverflowerror-or-freeze/116754/1 "2024-07-08T07:41:43Z")

</div>

[**Edit 2:** I’ve just posted a small program that reproduces this error in a separate message below.]

Can someone give me advice as to how to proceed when Julia crashes?

At first, I got the following error

```julia
[8865] signal (4.1): Illegal instruction: 4
in expression starting at none:0
_os_unfair_lock_recursive_abort at /usr/lib/system/libsystem_platform.dylib (unknown line)
_os_unfair_lock_lock_slow at /usr/lib/system/libsystem_platform.dylib (unknown line)
Allocations: 10807566 (Pool: 10799892; Big: 7674); GC: 21
fish: Job 1, 'julia ctw-superp-001.jl' terminated by signal SIGTRAP (Trace or breakpoint trap)

```

within a call to a `Makie` function.

My julia interpreter was up to date (1.10.4, because I keep it updated with `juliaup update`), but the packages weren’t. So, I entered the package manager and updated everything.

Then, I got

```julia
ERROR: LoadError: StackOverflowError:
in expression starting at . . . 

```

which points to the line of my program that calls the function that calls the `Makie` function that crashes.

I next I inserted some print statements (`display` or `@show`) before the function call which crashes to try to look at the arrays I send to the function. Then, the program freezes.

What’s the best way to proceed?

**Edit:** My code doesn’t involve any recursive calls. A print statement before the external crashing function prints on the screen but a call to `error()` after the crashing function is never reached. (Unless there were a callback from the crashing function to my code, there cannot be recursion involving my code.)

---

<div class="post-metadata">

### Author: ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)
#### Post date: [July 8, 2024, 7:45am UTC](https://discourse.julialang.org/t/crash-illegal-instruction-4-stackoverflowerror-or-freeze/116754/2 "2024-07-08T07:45:42Z")

</div>

> [@ryofurue](#):
>
> What’s the best way to proceed?

Reduce your code as much as you can without making the crash disappear and post it here 🙂

Are you doing any recursive calls yourself or do you think that this error occurs inside Makie.jl? Does it still happen when you remove all plotting functions?

---

<div class="post-metadata">

### Author: ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)
#### Post date: [July 8, 2024, 8:14am UTC](https://discourse.julialang.org/t/crash-illegal-instruction-4-stackoverflowerror-or-freeze/116754/3 "2024-07-08T08:14:48Z")

</div>

> [@abraemer](#):
>
> Are you doing any recursive calls yourself

No. I’ve added a comment about recursion at the end of my initial post for clarity to people who will read my initial post.

> [@abraemer](#):
>
> Reduce your code as much as you can without making the crash disappear

Okay.

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [July 8, 2024, 8:36am UTC](https://discourse.julialang.org/t/crash-illegal-instruction-4-stackoverflowerror-or-freeze/116754/4 "2024-07-08T08:36:45Z")

</div>

What is the Makie call that crashes?

---

<div class="post-metadata">

### Author: ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)
#### Post date: [July 8, 2024, 12:57pm UTC](https://discourse.julialang.org/t/crash-illegal-instruction-4-stackoverflowerror-or-freeze/116754/5 "2024-07-08T12:57:57Z")

</div>

```julia
c = contourf!(ax, xax, zax, xzarr)

```

After posting my question above, I found that I needed to convert `zax` to a normal array

```julia
  . . . , OffsetArrays.no_offset_view(zax), . . .)

```

I knew from experience that `Makie` doesn’t take OffsetArrays, but before this problem hit me, `Makie` used to issue an error message if I make the mistake of sending an OffsetArray.

So, I guess that there is some little bug in the Makie code that tries to convert arrays given as a parameter.

I’m now trying to minimize my code as much as possible. If successful, I’ll submit the example to the Makie repository.

---

<div class="post-metadata">

### Author: ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)
#### Post date: [July 9, 2024, 4:39am UTC](https://discourse.julialang.org/t/crash-illegal-instruction-4-stackoverflowerror-or-freeze/116754/6 "2024-07-09T04:39:37Z")

</div>

Here is a small-enough program that reproduces the error:

```julia
using CairoMakie
using OffsetArrays
(im, km_z) = (58, 38)
xax = 0:(im+1)
zax = OffsetArray(Vector{Float64}(undef, km_z+2), 0:km_z+1)

xzsect = zeros(Float64, size(xax,1), size(zax,1))

function plot_xz()
  nooffs = OffsetArrays.no_offset_view
  fig = Figure()
  ax = Axis(fig[1,1])
  c = contourf!(ax, xax, zax, nooffs(xzsect)) # -> StackOverflowError
# c = contourf!(ax, xax, nooffs(zax), nooffs(xzsect)) # <- fine
end

plot_xz()

```

In some cases, it produces the above `StackOverflowError` error without any stack trace. In other cases (I don’t see the pattern), it produces this error:

```bash
$ julia try-crash-02.jl

[96975] signal (4.1): Illegal instruction: 4
in expression starting at none:0
_os_unfair_lock_recursive_abort at /usr/lib/system/libsystem_platform.dylib (unknown line)
_os_unfair_lock_lock_slow at /usr/lib/system/libsystem_platform.dylib (unknown line)
Allocations: 7711446 (Pool: 7706794; Big: 4652); GC: 18
fish: Job 1, 'julia try-crash-02.jl' terminated by signal SIGTRAP (Trace or breakpoint trap)
$

```

where “$” is the shell prompt.

I’ve submitted this report to the Makie repository website.
