Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too long StackOverflowError backtrace #24592

Closed
mauro3 opened this issue Nov 13, 2017 · 3 comments · Fixed by #28016
Closed

Too long StackOverflowError backtrace #24592

mauro3 opened this issue Nov 13, 2017 · 3 comments · Fixed by #28016
Labels
error handling Handling of exceptions by Julia or the user

Comments

@mauro3
Copy link
Contributor

mauro3 commented Nov 13, 2017

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

@mauro3
Copy link
Contributor Author

mauro3 commented Nov 13, 2017

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.

@mauro3
Copy link
Contributor Author

mauro3 commented Jan 25, 2018

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)                                                                                                                     

@KristofferC
Copy link
Sponsor Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error handling Handling of exceptions by Julia or the user
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants