Skip to content

Conversation

@nsajko
Copy link
Contributor

@nsajko nsajko commented Jun 2, 2025

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

@github-actions
Copy link
Contributor

github-actions bot commented Jun 2, 2025

Your PR no longer requires formatting changes. Thank you for your contribution!

@codecov
Copy link

codecov bot commented Jun 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 47.64%. Comparing base (4981147) to head (fc8bf7d).
Report is 3 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nsajko
Copy link
Contributor Author

nsajko commented Jun 2, 2025

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

Copy link
Member

@vchuravy vchuravy left a 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

nsajko and others added 4 commits June 10, 2025 10:24
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
@vchuravy vchuravy merged commit 474050e into JuliaGPU:main Jun 10, 2025
32 of 33 checks passed
vchuravy added a commit that referenced this pull request Jun 10, 2025
Co-authored-by: Valentin Churavy <[email protected]>
(cherry picked from commit 474050e)
@nsajko nsajko deleted the prevent_get_backend_from_overflowing_the_stack branch June 10, 2025 13:03
vchuravy added a commit that referenced this pull request Jun 10, 2025
Co-authored-by: Valentin Churavy <[email protected]>
(cherry picked from commit 474050e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StackOverflowError on get_backend(::UnitRange)

2 participants