Skip to content
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

Sometimes get boundserror check in CI with v0.7 #43

Closed
disberd opened this issue Jul 23, 2024 · 4 comments
Closed

Sometimes get boundserror check in CI with v0.7 #43

disberd opened this issue Jul 23, 2024 · 4 comments

Comments

@disberd
Copy link

disberd commented Jul 23, 2024

First of all thanks a lot for the package @MasonProtter, I just started playing with it and it already seems very useful

I just updated a small package of mine that uses Bumper from v0.6 to v0.7.

I tested locally shortly and everything works but when I push on CI some of the tests fail (apparently randomly) with a boundscheck error

Here are two examples differeent CI runs where once it failed on ubunut and once on linux:
https://github.com/disberd/SlottedRandomAccess.jl/actions/runs/10055141472/job/27791169494
https://github.com/disberd/SlottedRandomAccess.jl/actions/runs/10054986890?pr=5

The error always seems to appear at this line below:
https://github.com/disberd/SlottedRandomAccess.jl/blob/7e9def4c5f7d6b383a0933b28272dbefd0a7c3d2/src/compute_plr.jl#L71

I did not investigate further here what might be the issue (or if I am using the library wrongly), but it did not seem to happen with v0.6 and it seems to happen randomly which is more worring :D.

@MasonProtter
Copy link
Owner

MasonProtter commented Jul 23, 2024

Ah interesting find! It appears the problem arises here: https://github.com/disberd/SlottedRandomAccess.jl/blob/7e9def4c5f7d6b383a0933b28272dbefd0a7c3d2/src/compute_plr.jl#L17

Your Poisson process can give 0, which means that you're creating a 0x100 matrix here, and it seems that UnsafeArrays.jl doesn't like dimensions of size zero.

Comparing against Array, we see

julia> Array{Float64}(undef, 0, 10)
0×10 Matrix{Float64}

julia> ans[:, 1] .= 1
0-element view(::Matrix{Float64}, :, 1) with eltype Float64

this correctly does nothing since the array is empty.

Whereas with UnsafeArrays, we have

julia> let A = Array{Float64}(undef, 0, 10)
           UA = UnsafeArray(pointer(A), (0, 10))
           UA[:, 1] .= 1
       end
ERROR: BoundsError: attempt to access 0×10 LinearIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}} at index [1, 1]
Stacktrace:

So the problem is really upstream in UnsafeArrays itself.

I'd recommend that in the short term, you remove or separately deal with the case where the random number generation gives 0, since you do a lot of unnecessary work in that case.

But in the meantime, I'll open an issue with UnsafeArrays.jl since it should handle this correctly.

@disberd
Copy link
Author

disberd commented Jul 23, 2024

Thanks a lot @MasonProtter for the super quick reply and for acqually finding a bug in my code :D.

I should have noticed based on the error but I forgot I was also doing poisson random...

@MasonProtter
Copy link
Owner

Happy I could help 😄

@MasonProtter
Copy link
Owner

Just an update @disberd the bug from upstream is now fixed: JuliaArrays/UnsafeArrays.jl#22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants