EmbarkStudios / EmbarkStudios/mirror-mirror
`value_to_usize` loses precision
- Dominant language
- Rust
- Stars
- 101
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
On 32-bits architectures, `usize` is 32-bits, by definition, so any conversion from a larger type into this will drop some bits. On 64-bits architecture, converting from 128-bits to 64-bits will also lose bits. It seems that it's only used for key paths computations, so for instance on 64-bits, that would require a static access in a list at an index >= 2**64 to cause an issue, so it's rather unlikely to happen, but it's still a real bug.
Contributor guide
Research direction
Search the repository for `value_to_usize` and trace its callers, especially the key-path computation code. Determine the intended behavior when a larger integer does not fit in `usize`, then inspect existing tests for a suitable regression case. Done means the conversion no longer silently loses precision on 32-bit or 64-bit architectures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100