8000 Ensure correct file length and sample skip calculations on 32-bit systems by using uint64_t by mmajoral · Pull Request #892 · gnss-sdr/gnss-sdr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Ensure correct file length and sample skip calculations on 32-bit systems by using uint64_t #892

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

Merged

Conversation

mmajoral
Copy link
Collaborator

Ensure correct file length and sample skip calculations on 32-bit systems by using uint64_t

On 32-bit architectures, size_t may not be large enough to represent large file sizes or sample counts. This update modifies the file length computation and the return type of samplesToSkip() to use uint64_t, allowing accurate handling of large files and ensuring consistency across platforms.

…tems by using uint64_t

On 32-bit architectures, size_t may not be large enough to represent large file
sizes or sample counts. This commit updates the file length computation and the
return type of samplesToSkip() to use uint64_t, allowing accurate handling of
large files and ensuring consistency across platforms.
@jwmelto
Copy link
Contributor
jwmelto commented May 28, 2025

Is there a failing test that this fixes? std::size_t is guaranteed to be large enough to represent any possible size. In particular,

If a program attempts to form an oversized type (i.e., the number of bytes in its object representation exceeds the maximum value representable in std::size_t), the program is ill-formed.

@mmajoral
Copy link
Collaborator Author
mmajoral commented May 28, 2025

Hi @jwmelto ,
I cross-compiled GNSS-SDR for the 32-bit ARM architecture on the Zynq-7000 platform, and ran it in post-processing mode. However, I encountered this issue: on the 32-bit platform, size_t appears to limit the maximum file size to 32 bits, causing GNSS-SDR to stop processing the input file earlier than expected.

I found some references, for example: https://stackoverflow.com/questions/918787/whats-sizeofsize-t-on-32-bit-vs-the-various-64-bit-data-models, which indicate that the C++ standard allows implementations to choose the representation of size_t, with range up to SIZE_MAX, which must be at least 65,535.

To verify this, I printed the size of size_t and the value of SIZE_MAX on both platforms:

PC (x86-64):
sizeof(size_t): 8 bytes
SIZE_MAX: 18446744073709551615

ARM (32-bit):
sizeof(size_t): 4 bytes
SIZE_MAX: 4294967295

Replacing size_t with uint64_t solved this issue.

@carlesfernandez carlesfernandez merged commit 80e5280 into gnss-sdr:next May 28, 2025
35 of 36 checks passed
@mmajoral mmajoral deleted the use-uint64_t-for-file-length branch May 30, 2025 14:15
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

Successfully merging this pull request may close these issues.

3 participants
0