-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
zero-argument getindex method in Base incorrectly assumes 1-based indexing #39379
Comments
The issue here is that |
No, that's working correctly. That method gets hit if you index into a non-zero-dimensional array with zero indices. It asserts that all axes have length 1. The problem is not in the bounds checking, but rather in the |
Here's the root problem: Line 1196 in 69d2453
Edit: This should probably be |
Thanks for debugging this further @mbauman. I think my original issue title is incorrect; I've changed it to what I think is an appropriate description. Feel free to change if there's a better or more correct title. |
to resolve a zero-index getindex to a linear index.
This is great! I wonder if a similar fix might be applied to #37274? |
It seems that the bounds check used in
Base
for zero-dimensional indexing hardcodes a comparison to1
, assuming one-based indexing.This means that an array with nonstandard axes can successfully pass the bounds check and then access out-of-bounds memory when indexing. I encountered this in an issue on OffsetArrays and @jishnub tracked it down to this line in
Base
:julia/base/abstractarray.jl
Line 642 in 69d2453
The text was updated successfully, but these errors were encountered: