<p dir="auto">The creation of a range using <code class="notranslate">range(start, step=..., length=...)</code> may result in a stack overflow if either of the start or step values is an <code class="notranslate">AbstractFloat</code> that is not one of the IEEE ones.</p>
<p dir="auto">Example:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; range(1.0, step=1, length=10)
1.0:1.0:10.0

julia&gt; range(big(1.0), step=1, length=10)
ERROR: StackOverflowError:
Stacktrace:
 [1] _range(::BigFloat, ::BigFloat, ::Nothing, ::Int64) at ./range.jl:105 (repeats 80000 times)

julia&gt; range(1.0, step=big(1.0), length=10)
ERROR: StackOverflowError:
Stacktrace:
 [1] _range(::BigFloat, ::BigFloat, ::Nothing, ::Int64) at ./range.jl:105 (repeats 80000 times)"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-c1">range</span>(<span class="pl-c1">1.0</span>, step<span class="pl-k">=</span><span class="pl-c1">1</span>, length<span class="pl-k">=</span><span class="pl-c1">10</span>)
<span class="pl-c1">1.0</span><span class="pl-k">:</span><span class="pl-c1">1.0</span><span class="pl-k">:</span><span class="pl-c1">10.0</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">range</span>(<span class="pl-c1">big</span>(<span class="pl-c1">1.0</span>), step<span class="pl-k">=</span><span class="pl-c1">1</span>, length<span class="pl-k">=</span><span class="pl-c1">10</span>)
ERROR<span class="pl-k">:</span> StackOverflowError<span class="pl-k">:</span>
Stacktrace<span class="pl-k">:</span>
 [<span class="pl-c1">1</span>] <span class="pl-c1">_range</span>(<span class="pl-k">::</span><span class="pl-c1">BigFloat</span>, <span class="pl-k">::</span><span class="pl-c1">BigFloat</span>, <span class="pl-k">::</span><span class="pl-c1">Nothing</span>, <span class="pl-k">::</span><span class="pl-c1">Int64</span>) at <span class="pl-k">./</span>range<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">105</span> (repeats <span class="pl-c1">80000</span> times)

julia<span class="pl-k">&gt;</span> <span class="pl-c1">range</span>(<span class="pl-c1">1.0</span>, step<span class="pl-k">=</span><span class="pl-c1">big</span>(<span class="pl-c1">1.0</span>), length<span class="pl-k">=</span><span class="pl-c1">10</span>)
ERROR<span class="pl-k">:</span> StackOverflowError<span class="pl-k">:</span>
Stacktrace<span class="pl-k">:</span>
 [<span class="pl-c1">1</span>] <span class="pl-c1">_range</span>(<span class="pl-k">::</span><span class="pl-c1">BigFloat</span>, <span class="pl-k">::</span><span class="pl-c1">BigFloat</span>, <span class="pl-k">::</span><span class="pl-c1">Nothing</span>, <span class="pl-k">::</span><span class="pl-c1">Int64</span>) at <span class="pl-k">./</span>range<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">105</span> (repeats <span class="pl-c1">80000</span> times)</pre></div>
<p dir="auto">This seems to be the case since v0.7, I currently tested on v1.1.</p>
<p dir="auto">The culprit is <code class="notranslate">_range</code> in <code class="notranslate">range.jl</code>, more specifically <a href="https://github.com/JuliaLang/julia/blob/v1.1.0/base/range.jl#L105">this line</a>. In case <code class="notranslate">start</code> and <code class="notranslate">step</code> are any combination of an <code class="notranslate">AbstractFloat</code> and a <code class="notranslate">Real</code>, the logic in <code class="notranslate">_range</code> promotes them to the same floating point type.</p>
<p dir="auto">However, the subsequent call to <code class="notranslate">_range</code> with equal types is intercepted only for IEEE types elsewhere in <code class="notranslate">twiceprecision.jl</code>, specifically <a href="https://github.com/JuliaLang/julia/blob/v1.1.0/base/twiceprecision.jl#L427">here</a>. There is no alternative fallback, hence the stack overflow.</p>
<p dir="auto">The solution might simply be to add a fallback in <code class="notranslate">range.jl</code>, such as</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="_range(a::T, step::T, ::Nothing, len::Integer) where {T &lt;: AbstractFloat} =
    _rangestyle(OrderStyle(T), ArithmeticStyle(T), a, step, len)"><pre class="notranslate"><code class="notranslate">_range(a::T, step::T, ::Nothing, len::Integer) where {T &lt;: AbstractFloat} =
    _rangestyle(OrderStyle(T), ArithmeticStyle(T), a, step, len)
</code></pre></div>
<p dir="auto">This is similar to the line further <a href="https://github.com/JuliaLang/julia/blob/v1.1.0/base/range.jl#L110">below</a>.</p>
<p dir="auto">Note that I did NOT test the above solution, sorry, as I've never changed anything in base and I have no working julia build to do so :-)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; BigFloat(2)*(1:2)
ERROR: StackOverflowError:
Stacktrace:
 [1] range(::BigFloat, ::BigFloat, ::Int64) at ./range.jl:74 (repeats 80000 times)

julia&gt; versioninfo()
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-2620M CPU @ 2.70GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, sandybridge)"><pre class="notranslate"><code class="notranslate">julia&gt; BigFloat(2)*(1:2)
ERROR: StackOverflowError:
Stacktrace:
 [1] range(::BigFloat, ::BigFloat, ::Int64) at ./range.jl:74 (repeats 80000 times)

julia&gt; versioninfo()
Julia Version 0.6.2
Commit d386e40c17 (2017-12-13 18:08 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-2620M CPU @ 2.70GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, sandybridge)
</code></pre></div>