- 
                Notifications
    You must be signed in to change notification settings 
- Fork 79
          prevent get_backend from overflowing the stack
          #602
        
          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
  
    prevent get_backend from overflowing the stack
  
  #602
              Conversation
| Your PR no longer requires formatting changes. Thank you for your contribution! | 
| Codecov ReportAll modified and coverable lines are covered by tests ✅ 
 Additional details and impacted files@@            Coverage Diff             @@
##             main     #602      +/-   ##
==========================================
+ Coverage   47.52%   47.64%   +0.12%     
==========================================
  Files          22       22              
  Lines        1715     1719       +4     
==========================================
+ Hits          815      819       +4     
  Misses        900      900              ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
 | 
| This is how it looks now: julia> using KernelAbstractions
Precompiling KernelAbstractions...
  37 dependencies successfully precompiled in 60 seconds. 29 already precompiled.
julia> struct UnknownAbstractVector <: AbstractVector{Float32} end
julia> get_backend(UnknownAbstractVector())
ERROR: ArgumentError: throwing to prevent a stack overflow, possibly a `get_backend` method is missing?
Stacktrace:
 [1] (::KernelAbstractions.var"#t#1")()
   @ KernelAbstractions ~/tmp/jl/KernelAbstractions.jl/src/KernelAbstractions.jl:514
 [2] get_backend_recur(f::typeof(parent), x::UnknownAbstractVector)
   @ KernelAbstractions ~/tmp/jl/KernelAbstractions.jl/src/KernelAbstractions.jl:517
 [3] get_backend(A::UnknownAbstractVector)
   @ KernelAbstractions ~/tmp/jl/KernelAbstractions.jl/src/KernelAbstractions.jl:523
 [4] top-level scope
   @ REPL[4]:1 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I will backport this to the 0.9 branch
Prevent the `get_backend` methods from overflowing the stack/recurring without bound. Hoping this doesn't cause inference issues due to deeper call stacks. Fixes #588
Co-authored-by: Valentin Churavy <[email protected]>
Co-authored-by: Valentin Churavy <[email protected]> (cherry picked from commit 474050e)
Co-authored-by: Valentin Churavy <[email protected]> (cherry picked from commit 474050e)
Prevent the
get_backendmethods from overflowing the stack/recurring without bound.Hoping this doesn't cause inference issues due to deeper call stacks.
Fixes #588