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

Handling Large Offsets for read on 32-bit Systems May Exceed usize Capacity #4506

Open
shbhmrzd opened this issue Apr 22, 2024 · 4 comments
Open

Comments

@shbhmrzd
Copy link
Contributor

A potential issue in the system where i64 is used for file offsets. On 32-bit architectures, usize is limited to 2^31-1, which means that offsets near the upper limit of i64 could exceed usize capacities. This can lead to runtime errors or panics if not properly handled.

@shbhmrzd shbhmrzd changed the title Handling Large Offsets on 32-bit Systems May Exceed usize Capacity Handling Large Offsets for read on 32-bit Systems May Exceed usize Capacity Apr 22, 2024
@shbhmrzd
Copy link
Contributor Author

@Xuanwo
Just changing u64 in api.rs for all offset to usize followed by changes in all implementations should be fine, right?
Can I take it up?
Thank you!

@Xuanwo
Copy link
Member

Xuanwo commented Apr 22, 2024

Just changing u64 in api.rs for all offset to usize followed by changes in all implementations should be fine, right?

I don't have plan to change it yet. Please note that u64 is fine on 32 bit systems is ok.

@shbhmrzd
Copy link
Contributor Author

Just changing u64 in api.rs for all offset to usize followed by changes in all implementations should be fine, right?

I don't have plan to change it yet. Please note that u64 is fine on 32 bit systems is ok.

I think if the underlying client uses usize then it could be an issue if the offset provided is pretty large. If the client itself has u64 then it should not be an issue. Please let me know if this understanding is incorrect.

@Xuanwo
Copy link
Member

Xuanwo commented Apr 22, 2024

I think if the underlying client uses usize then it could be an issue if the offset provided is pretty large.

Your understanding is correct. However, the proper solution is to have the underlying client accept u64 instead. Changing u64 to usize is incorrect.

That said, there's no immediate need to address this. We can revisit the issue if we encounter it with users on 32-bit systems.

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