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

deleteat! : check bounds for the first passed index #36231

Merged
merged 2 commits into from
Jun 16, 2020

Conversation

rfourquet
Copy link
Member

All other indices are bound-checked.
Currently, the behavior looks like:

julia> deleteat!([1:1000;], [-100])

signal (11): Segmentation fault
[...]

julia>  deleteat!(BigInt[0], [0])
free(): invalid next size (normal)

signal (6): Aborted
[...]

julia> deleteat!(BigInt[0], [-100])
ERROR: UndefRefError: access to undefined reference
[...]

julia> deleteat!([0], [0])
Int64[]

julia> deleteat!([0], [2])
1-element Array{Int64,1}:
 0

julia> deleteat!([0], [3])
ERROR: InexactError: check_top_bit(UInt64, -1)
[...]

With this commit, all these expressions throw a BoundsError.

All other indices are bound-checked.
Currently, the behavior looks like:
```julia
julia> deleteat!([1:1000;], [-100])

signal (11): Segmentation fault
[...]

julia>  deleteat!(BigInt[0], [0])
free(): invalid next size (normal)

signal (6): Aborted
[...]

julia> deleteat!(BigInt[0], [-100])
ERROR: UndefRefError: access to undefined reference
[...]

julia> deleteat!([0], [0])
Int64[]

julia> deleteat!([0], [2])
1-element Array{Int64,1}:
 0

julia> deleteat!([0], [3])
ERROR: InexactError: check_top_bit(UInt64, -1)
[...]
```
With this commit, all these expressions throw a `BoundsError`.
@rfourquet rfourquet added arrays [a, r, r, a, y, s] bugfix This change fixes an existing bug labels Jun 11, 2020
base/array.jl Outdated Show resolved Hide resolved
@JeffBezanson
Copy link
Sponsor Member

Wow, good catch.

Co-authored-by: Simeon Schaub <[email protected]>
@KristofferC KristofferC merged commit 6cdfcf9 into master Jun 16, 2020
@KristofferC KristofferC deleted the rf/deleteat-bounds branch June 16, 2020 17:47
KristofferC pushed a commit that referenced this pull request Jun 16, 2020
* deleteat! : check bounds for the first passed index

All other indices are bound-checked.
Currently, the behavior looks like:
```julia
julia> deleteat!([1:1000;], [-100])

signal (11): Segmentation fault
[...]

julia>  deleteat!(BigInt[0], [0])
free(): invalid next size (normal)

signal (6): Aborted
[...]

julia> deleteat!(BigInt[0], [-100])
ERROR: UndefRefError: access to undefined reference
[...]

julia> deleteat!([0], [0])
Int64[]

julia> deleteat!([0], [2])
1-element Array{Int64,1}:
 0

julia> deleteat!([0], [3])
ERROR: InexactError: check_top_bit(UInt64, -1)
[...]
```
With this commit, all these expressions throw a `BoundsError`.

* Update base/array.jl

Co-authored-by: Simeon Schaub <[email protected]>

Co-authored-by: Simeon Schaub <[email protected]>
(cherry picked from commit 6cdfcf9)
simeonschaub added a commit to simeonschaub/julia that referenced this pull request Aug 11, 2020
* deleteat! : check bounds for the first passed index

All other indices are bound-checked.
Currently, the behavior looks like:
```julia
julia> deleteat!([1:1000;], [-100])

signal (11): Segmentation fault
[...]

julia>  deleteat!(BigInt[0], [0])
free(): invalid next size (normal)

signal (6): Aborted
[...]

julia> deleteat!(BigInt[0], [-100])
ERROR: UndefRefError: access to undefined reference
[...]

julia> deleteat!([0], [0])
Int64[]

julia> deleteat!([0], [2])
1-element Array{Int64,1}:
 0

julia> deleteat!([0], [3])
ERROR: InexactError: check_top_bit(UInt64, -1)
[...]
```
With this commit, all these expressions throw a `BoundsError`.

* Update base/array.jl

Co-authored-by: Simeon Schaub <[email protected]>

Co-authored-by: Simeon Schaub <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s] bugfix This change fixes an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants