Julia: Too long StackOverflowError backtrace

Created on 13 Nov 2017  路  3Comments  路  Source: JuliaLang/julia

Running this produces 80000 lines of errors:

   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.7.0-DEV.2490 (2017-11-11 17:03 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit da34a89917* (1 day old master)
|__/                   |  x86_64-pc-linux-gnu

julia> using Rotations, StaticArrays

julia> (::Type{Rotations.RotMatrix{N,T,L}})(sa::StaticArrays.StaticMatrix) where {N,T,L} =
           Rotations.RotMatrix(sa)                                                                                                                                       

julia> RotMatrix(-4.5)                                                                                                                                                   
ERROR: StackOverflowError:                                                                                                                                               
Stacktrace:                                                                                                                                                              
 [1] Rotations.RotMatrix(::StaticArrays.SArray{Tuple{2,2},Float64,2,4}) at /home/mauro/.julia/v0.6/Rotations/src/core_types.jl:80                                        
 [2] Rotations.RotMatrix{2,Float64,4}(::StaticArrays.SArray{Tuple{2,2},Float64,2,4}) at ./REPL[3]:1                                                                      
...
 [79999] Rotations.RotMatrix(::StaticArrays.SArray{Tuple{2,2},Float64,2,4}) at /home/mauro/.julia/v0.6/Rotations/src/core_types.jl:80                                    
 [80000] Rotations.RotMatrix{2,Float64,4}(::StaticArrays.SArray{Tuple{2,2},Float64,2,4}) at ./REPL[3]:1

Same on 0.6.1

error handling

Most helpful comment

Random keywords to make this easier to find: Long stacktrace in stackoverflow recursion.

All 3 comments

Note when defining instead:

julia> (::Type{Rotations.RotMatrix{N,T,L}})(sa::StaticArrays.StaticMatrix) where {N,T,L} =
           Rotations.RotMatrix{N,T,L}(sa)                                                                                                                                

julia> RotMatrix(-4.5)                                                                                                                                                   
ERROR: StackOverflowError:                                                                                                                                               
Stacktrace:                                                                                                                                                              
 [1] Rotations.RotMatrix{2,Float64,4}(::StaticArrays.SArray{Tuple{2,2},Float64,2,4}) at ./REPL[2]:1 (repeats 80000 times)                                                

then the lines get folded into one. I guess the problem is the 2-fold infinite recursion.

Simpler:

julia> g(x) = h(x)                                                                                                                                                       
g (generic function with 1 method)                                                                                                                                       

julia> h(x) = g(x)                                                                                                                                                       
h (generic function with 1 method)                                                                                                                                       

julia> g(5)
ERROR: StackOverflowError:                                                                                                                                               
Stacktrace:             
....
 [79998] h(::Int64) at ./REPL[4]:1                                                                                                                                       
 [79999] g(::Int64) at ./REPL[3]:1                                                                                                                                       
 [80000] h(::Int64) at ./REPL[4]:1                                                                                                                                       

whereas a simple recursion throws a good error:

julia> f(x) = f(x)                                                                                                                                                       
f (generic function with 1 method)                                                                                                                                       

julia> f(5)                                                                                                                                                              
ERROR: StackOverflowError:                                                                                                                                               
Stacktrace:                                                                                                                                                              
 [1] f(::Int64) at ./REPL[1]:1 (repeats 80000 times)                                                                                                                     

Random keywords to make this easier to find: Long stacktrace in stackoverflow recursion.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Keno picture Keno  路  3Comments

sbromberger picture sbromberger  路  3Comments

StefanKarpinski picture StefanKarpinski  路  3Comments

iamed2 picture iamed2  路  3Comments

omus picture omus  路  3Comments