Skip to content

prevent get_backend from overflowing the stack - #602

Merged
vchuravy merged 4 commits into
JuliaGPU:mainfrom
nsajko:prevent_get_backend_from_overflowing_the_stack
Jun 10, 2025
Merged

prevent get_backend from overflowing the stack#602
vchuravy merged 4 commits into
JuliaGPU:mainfrom
nsajko:prevent_get_backend_from_overflowing_the_stack

Conversation

@nsajko

@nsajko nsajko commented Jun 2, 2025

Copy link
Copy Markdown
Contributor

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

github-actions Bot commented Jun 2, 2025

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jun 2, 2025

Copy link
Copy Markdown

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

nsajko commented Jun 2, 2025

Copy link
Copy Markdown
Contributor Author

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

Comment thread src/KernelAbstractions.jl Outdated
Comment thread ext/LinearAlgebraExt.jl Outdated
Comment thread src/KernelAbstractions.jl Outdated

@vchuravy vchuravy left a comment

Copy link
Copy Markdown
Member

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
Co-authored-by: Valentin Churavy <v.churavy@gmail.com>
@vchuravy
vchuravy merged commit 474050e into JuliaGPU:main Jun 10, 2025
vchuravy added a commit that referenced this pull request Jun 10, 2025
Co-authored-by: Valentin Churavy <v.churavy@gmail.com>
(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 <v.churavy@gmail.com>
(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