# Mysterious \`StackOverFlow\` error with type constructor when using \`PyPlot\` in conjunction with \`Reduce\`

**URL:** <https://discourse.julialang.org/t/mysterious-stackoverflow-error-with-type-constructor-when-using-pyplot-in-conjunction-with-reduce/14050>\
**Category:** General Usage\
**Tags:** question, type, error\
**Created:** [August 25, 2018, 5:29pm UTC](https://discourse.julialang.org/t/mysterious-stackoverflow-error-with-type-constructor-when-using-pyplot-in-conjunction-with-reduce/14050 "2018-08-25T17:29:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [August 25, 2018, 5:29pm UTC](https://discourse.julialang.org/t/mysterious-stackoverflow-error-with-type-constructor-when-using-pyplot-in-conjunction-with-reduce/14050/1 "2018-08-25T17:29:06Z")

</div>

It’s not clear how to resolve this `StackOverFlow` error, call to `mandelbrot` calls a `Define` type constructor:

```nohighlight
pkg> dev Fatou

julia> using Fatou

julia> mandelbrot(:(z^3-1))
ERROR: StackOverflowError:
Stacktrace:
 [1] Type at ./none:0 [inlined]
 [2] #mandelbrot#4 at /home/flow/.julia/dev/Fatou/src/Fatou.jl:185 [inlined]
 [3] mandelbrot(::Expr) at /home/flow/.julia/dev/Fatou/src/Fatou.jl:184
 [4] top-level scope at none:0

```

Can’t figure out what’s the cause of this, it worked fine in 0.6 but not 1.0

> **[GitHub - chakravala/Fatou.jl: Fatou sets in Julia (Fractals, Newton basins,...](https://github.com/chakravala/Fatou.jl)**
>
> Fatou sets in Julia (Fractals, Newton basins, Mandelbrot) - GitHub - chakravala/Fatou.jl: Fatou sets in Julia (Fractals, Newton basins, Mandelbrot)

---

<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:** [August 25, 2018, 5:36pm UTC](https://discourse.julialang.org/t/mysterious-stackoverflow-error-with-type-constructor-when-using-pyplot-in-conjunction-with-reduce/14050/2 "2018-08-25T17:36:45Z")

</div>

It would help to have an MWE, Fatou has quite a few dependencies.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [August 25, 2018, 6:34pm UTC](https://discourse.julialang.org/t/mysterious-stackoverflow-error-with-type-constructor-when-using-pyplot-in-conjunction-with-reduce/14050/5 "2018-08-25T18:34:52Z")

</div>

If any of those 17 parameters are removed, the issue is solved? I’m guessing they are important since you included them in MWE.

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [August 25, 2018, 8:21pm UTC](https://discourse.julialang.org/t/mysterious-stackoverflow-error-with-type-constructor-when-using-pyplot-in-conjunction-with-reduce/14050/7 "2018-08-25T20:21:55Z")

</div>

Alright, here is the official **minimum working example** :

```nohighlight
julia> module MWE
       using Reduce,PyPlot
       test(a) = RExpr(a)
       end
Reduce (Free CSL version, revision 4590), 11-May-18 ...
Main.MWE

julia> MWE.test(:(z^3-1))
ERROR: StackOverflowError:
Stacktrace:
 [1] top-level scope at none:0

```

However, if you remove the `PyPlot` dependency then

```nohighlight
julia> module MWE
       using Reduce
       test(a) = RExpr(a)
       end
Reduce (Free CSL version, revision 4590), 11-May-18 ...
Main.MWE

julia> MWE.test(:(z^3-1))

 3
z - 1

```

works without any error.

Therefore, it is now clear that when `using Reduce, PyPlot` there is a strange issue happening with the `RExpr` type constructor causing a `StackOverFlow` error. Is this a Julia language bug or a `PyPlot` bug?

Anybody know what’s causing this, if it’s julia or `PyPlot`? @Tamas_Papp @kristoffer.carlsson

---

<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:** [August 26, 2018, 5:14am UTC](https://discourse.julialang.org/t/mysterious-stackoverflow-error-with-type-constructor-when-using-pyplot-in-conjunction-with-reduce/14050/8 "2018-08-26T05:14:47Z")

</div>

> [@chakravala](#):
>
> here is the official **minimum working example**

This is not really minimal, as it involves two packages, with rather heavy dependencies.

If you weren’t its maintaner, I would recommend opening an issue for Reduce, but in this case your best solution is probably just isolating the problem, eg by `dev`ing both packages and then commenting out parts, _then_ making a _self-contained MWE_ which you can use for figuring out a fix or opening an issue.

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [August 26, 2018, 5:38am UTC](https://discourse.julialang.org/t/mysterious-stackoverflow-error-with-type-constructor-when-using-pyplot-in-conjunction-with-reduce/14050/9 "2018-08-26T05:38:44Z")

</div>

That sure describes the process I had in mind for isolating it down further as well. I’ve got other things to do in life, what I post here is more of a public reminder to myself and others for centering in on the issue. When I’m not worried about other things I might narrow it down further, but since this is a public discussion, others are welcome to provide feedback.

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [October 2, 2018, 8:16pm UTC](https://discourse.julialang.org/t/mysterious-stackoverflow-error-with-type-constructor-when-using-pyplot-in-conjunction-with-reduce/14050/10 "2018-10-02T20:16:36Z")

</div>

Looks like Julia version 1.0.1 fixes this issue! So it wasn’t an issue with `Reduce` or `PyPlot` but Julia itself.
