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

Should std::slice::from_raw_parts document that slices larger than isize::MAX are unsound? #53676

Closed
oconnor663 opened this issue Aug 24, 2018 · 0 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools

Comments

@oconnor663
Copy link
Contributor

Indexing into a slice relies on ptr::offset, which says that its UB to use an offset/index larger than isize::MAX. As documented by ptr::offset, "memory acquired directly from allocators or memory mapped files may be too large to handle with this function." Does that mean that e.g. memory mapping a file larger than isize::MAX into a slice is unsound, because safe code can cause UB just by indexing into it? Should the from_raw_parts docs tell callers that they need to check this?

@Havvy Havvy added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Aug 25, 2018
tbu- added a commit to tbu-/rust that referenced this issue Sep 4, 2018
kennytm added a commit to kennytm/rust that referenced this issue Oct 1, 2018
…Jung

Document that slices cannot be larger than `isize::MAX` bytes

Fixes rust-lang#53676.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools
Projects
None yet
Development

No branches or pull requests

2 participants