# Infinite recursion kills Julia instead of stackoverflowing

**URL:** https://discourse.julialang.org/t/infinite-recursion-kills-julia-instead-of-stackoverflowing/31819
**Category:** General Usage
**Created:** [December 3, 2019, 9:06pm UTC](https://discourse.julialang.org/t/infinite-recursion-kills-julia-instead-of-stackoverflowing/31819 "2019-12-03T21:06:57Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [December 3, 2019, 9:06pm UTC](https://discourse.julialang.org/t/infinite-recursion-kills-julia-instead-of-stackoverflowing/31819/1 "2019-12-03T21:06:57Z")

</div>

This is fine

```julia
julia> function recur(var::String)
       recur("Ai")
       end
recur (generic function with 1 method)

julia> recur("ai")
ERROR: StackOverflowError:
Stacktrace:
 [1] recur(::String) at .\REPL[2]:2 (repeats 65280 times)
 [2] top-level scope at REPL[3]:1

```

But I have this bugged [function](https://github.com/GenericMappingTools/GMT.jl/blob/master/src/imshow.jl) that falls into an infinite recursive loop, when first argument is a string, and it kills Julia instead of stopping with the `StackOverflowError:` error.

I added it a counter and it crashed at 11804 iteration.

```julia
imshow("tut_relief.nc", proj=:Mercator, zsize=1, view=(135,30))

```

Can open an issue but won’t be able to give more info than this.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [December 4, 2019, 6:05am UTC](https://discourse.julialang.org/t/infinite-recursion-kills-julia-instead-of-stackoverflowing/31819/2 "2019-12-04T06:05:11Z")

</div>

> [@joa-quim](#):
>
> won’t be able to give more info than this.

🤷‍♂️ Without an MWE, it is very unlikely that this will be investigated in depth.

---

<div class="post-metadata">

### Author: ![jkbest2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jkbest2/32/7350_2.png) [@jkbest2](https://discourse.julialang.org/u/jkbest2)
#### Post date: [December 4, 2019, 6:25am UTC](https://discourse.julialang.org/t/infinite-recursion-kills-julia-instead-of-stackoverflowing/31819/3 "2019-12-04T06:25:38Z")

</div>

Could it have run out of memory before getting to a stack overflow? That would kill the Julia process. You could run your code again and watch your RAM usage. If this is the case there’s not much to do but change the code or use a machine with more memory.

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [December 4, 2019, 11:10am UTC](https://discourse.julialang.org/t/infinite-recursion-kills-julia-instead-of-stackoverflowing/31819/4 "2019-12-04T11:10:13Z")

</div>

One needs GMT.jl to reproduce this, but then is very simple. It’s a silent _death_.  
And, no, it doesn’t seem a memory problem. No visible raise in memory use (run in 32 GB ram computer)

 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/2/c23c3adcc6f67b93fa38d9f1cf42058e54491692.png)

---

<div class="post-metadata">

### Author: ![tshort](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tshort/32/43_2.png) [@tshort](https://discourse.julialang.org/u/tshort)
#### Post date: [December 4, 2019, 3:10pm UTC](https://discourse.julialang.org/t/infinite-recursion-kills-julia-instead-of-stackoverflowing/31819/5 "2019-12-04T15:10:02Z")

</div>

I can’t reproduce your crash with GMT. For me, that gives a stack overflow. I also used v1.3.0 under windows.

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [December 4, 2019, 4:27pm UTC](https://discourse.julialang.org/t/infinite-recursion-kills-julia-instead-of-stackoverflowing/31819/6 "2019-12-04T16:27:15Z")

</div>

Hmm, that’s rather strange. I have some uncommitted changes and master is also a bit ahead of last 0.12.0 version. Now I have no time, but tonight I’ll commit everything I have and then ask you if you can try with master.

Note that this call of `imshow` does not even goes to the GMT C libs, so it’s a pure Julia thing (for me at least).

… and thanks for testing.

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [December 5, 2019, 2:35pm UTC](https://discourse.julialang.org/t/infinite-recursion-kills-julia-instead-of-stackoverflowing/31819/7 "2019-12-05T14:35:40Z")

</div>

Continue puzzled. Installed in another computer and there I also get the `stack overflow`, but in the laptop it always kill my julia session. Guess I have to wait that some luck brings out light on this issue.
