Skip to content

uint64 can exceed Nix integer range #185

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

Closed
Scandiravian opened this issue Mar 28, 2025 · 7 comments · Fixed by #193
Closed

uint64 can exceed Nix integer range #185

Scandiravian opened this issue Mar 28, 2025 · 7 comments · Fixed by #193
Assignees

Comments

@Scandiravian
Copy link

An integer in Nix is always signed, which can lead to issues when a number exceeds 2^63 - 1.

For instance, I ran nixos-facter on a Dell R760 server, which sets the value of an entry in hardware.memory_array_mapped_address to 18446741876833779712. This makes the nix configuration fail to build when anything references the report as JSON seems to be eagerly loaded by nix.

This is clearly an edge case, but would it be possible to use strings instead of uint64 in the output for these values?

@brianmcgee brianmcgee self-assigned this Mar 29, 2025
@brianmcgee
Copy link
Collaborator

🤔 I'll have a look a bit later this week.

@Scandiravian
Copy link
Author

Please let me know if there's anything I can do to help. I have some experience in Go and since this related to my work, I can spend a bit of time on it.

Do you know what an ideal solution to this would look like for you (if you think this should be fixed)? If you let me know I can look into implementing it

Thanks for all the work you're putting into this project - facter is an extremely useful tool for me!

@brianmcgee
Copy link
Collaborator

@Scandiravian, I'm glad to hear you find it helpful.

I will try to think through the implications for a bit today. I'll post my thoughts here.

Happy to review PRs if you want to implement the fix 🙏

@songpola
Copy link

songpola commented Apr 6, 2025

Yes. I got this error too: error: unsigned json number 9223372036854775808 outside of Nix integer range

Cause by:

$ jq '.smbios.memory_64_error[] | {array_address, device_address}' facter.json
{
  "array_address": 9223372036854775808,
  "device_address": 9223372036854775808
}

@brianmcgee
Copy link
Collaborator

A quick review of mapping from hwinfo s underlying data model shows some places I can reduce the size from uint.

I'll spend some time today doing this and converting any explicit usages of uint64_t to string and see if anything breaks in nixos-facter-modules. I don't think any values are actively being used, so I can safely break the format without a version bump.

@Mic92
Copy link
Member

Mic92 commented Apr 7, 2025

@brianmcgee maybe a those addresses could be formatted as hex strings. That's also more readable and compact.

@Scandiravian
Copy link
Author

I've just tested #193 on the R760 servers, that were experiencing the issue and the fix resolved it 😊

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 a pull request may close this issue.

4 participants