-
Notifications
You must be signed in to change notification settings - Fork 14
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
Indexing out-of-bounds not throwing #67
Comments
julia> StrideArraysCore.boundscheck() = true
julia> nn(randn(10), SimpleChains.init_params(nn))[2]
ERROR: BoundsError: attempt to access 1-element PtrArray{Tuple{StaticInt{1}}, (true,), Float64, 1, 1, 0, (1,), Tuple{StaticInt{8}}, Tuple{StaticInt{1}}} with indices 1:1:1 at index [2]
Stacktrace:
[1] throw_boundserror(A::PtrArray{Tuple{StaticInt{1}}, (true,), Float64, 1, 1, 0, (1,), Tuple{StaticInt{8}}, Tuple{StaticInt{1}}}, I::Tuple{Int64})
@ Base ./abstractarray.jl:703
[2] checkbounds
@ ./abstractarray.jl:668 [inlined]
[3] getindex(A::PtrArray{Tuple{StaticInt{1}}, (true,), Float64, 1, 1, 0, (1,), Tuple{StaticInt{8}}, Tuple{StaticInt{1}}}, i::Int64)
@ StrideArraysCore ~/.julia/packages/StrideArraysCore/pjIfM/src/ptr_array.jl:569
[4] top-level scope
@ REPL[8]:1 There are a ton of functions in the Julia ecosystem that don't have |
Note that if you start Julia with julia> using SimpleChains
julia> nn = SimpleChain(
static(10),
TurboDense(identity, 1),
)
SimpleChain with the following layers:
TurboDense static(1) with bias.
julia> nn(randn(10), SimpleChains.init_params(nn))[2]
ERROR: BoundsError: attempt to access 1-element StrideArraysCore.PtrArray{Tuple{Static.StaticInt{1}}, (true,), Float64, 1, 1, 0, (1,), Tuple{Static.StaticInt{8}}, Tuple{Static.StaticInt{1}}} with indices 1:1:1 at index [2]
Stacktrace:
[1] throw_boundserror(A::StrideArraysCore.PtrArray{Tuple{Static.StaticInt{1}}, (true,), Float64, 1, 1, 0, (1,), Tuple{Static.StaticInt{8}}, Tuple{Static.StaticInt{1}}}, I::Tuple{Int64})
@ Base ./abstractarray.jl:703
[2] checkbounds
@ ./abstractarray.jl:668 [inlined]
[3] getindex(A::StrideArraysCore.PtrArray{Tuple{Static.StaticInt{1}}, (true,), Float64, 1, 1, 0, (1,), Tuple{Static.StaticInt{8}}, Tuple{Static.StaticInt{1}}}, i::Int64)
@ StrideArraysCore ~/.julia/packages/StrideArraysCore/pjIfM/src/ptr_array.jl:569
[4] top-level scope
@ REPL[3]:1 |
Ok, so a general fix for this would impact performance too much - leaving it up to the documentation to be explicit about the danger? |
I guess it isn't obvious to anyone where to look/maybe it should be plastered everywhere? https://github.com/JuliaSIMD/StrideArraysCore.jl#caution |
This seems like a bit of a footgun. Indeed, my foot is not unscathed.
The text was updated successfully, but these errors were encountered: