You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems using c_longlonghttps://doc.rust-lang.org/stable/std/ffi/type.c_longlong.html should fix the issue along with pyo3::ffi::PyLong_FromLongLong(start as std::ffi::c_longlong) which are defined to be at least i64 on most systems (including Windows x64bit where isize is i64 and c_long is not, which is the core of this issue)
Steps to Reproduce
Create a slice with either value being over i32::MAX. (it will silently overflow to negative values).
Backtrace
No response
Your operating system and version
Windows (any afaik)
Your Python version (python --version)
Any (afaik)
Your Rust version (rustc --version)
1.65 (but any)
Your PyO3 version
0.17.2
How did you install python? Did you use a virtualenv?
Bug Description
When trying to take a large slice with
PySlice::new(start, stop, step)
one, can overflow and get back an erroneous answer on Windows platform.Core of the issue seems to be here:
https://docs.rs/pyo3/latest/src/pyo3/types/slice.rs.html#43-52
https://doc.rust-lang.org/stable/std/ffi/type.c_long.html Which is said to be
i32
on Windows platform.It seems using
c_longlong
https://doc.rust-lang.org/stable/std/ffi/type.c_longlong.html should fix the issue along withpyo3::ffi::PyLong_FromLongLong(start as std::ffi::c_longlong)
which are defined to be at leasti64
on most systems (including Windows x64bit where isize is i64 and c_long is not, which is the core of this issue)Steps to Reproduce
Create a slice with either value being over
i32::MAX
. (it will silently overflow to negative values).Backtrace
No response
Your operating system and version
Windows (any afaik)
Your Python version (
python --version
)Any (afaik)
Your Rust version (
rustc --version
)1.65 (but any)
Your PyO3 version
0.17.2
How did you install python? Did you use a virtualenv?
pyenv but all are affected afaik
Additional Info
Original report: huggingface/safetensors#95
Temporary fix in the lib itself huggingface/safetensors#99
Happy to contribute a PR if wanted.
@davidhewitt for visibility.
The text was updated successfully, but these errors were encountered: