crash when parsing large binary numbers using builtins.fromTOML
#914
Labels
No labels
Affects/CppNix
Affects/Nightly
Affects/Only nightly
Affects/Stable
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/lix ci
Area/nix-eval-jobs
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/repl/debugger
Area/store
bug
Context
contributors
Context
drive-by
Context
maintainers
Context
RFD
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
imported
Language/Bash
Language/C++
Language/NixLang
Language/Python
Language/Rust
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
Topic/Large Scale Installations
ux
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#914
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Describe the bug
evaluating
builtins.fromTOML
terminates evaluation with sigill if given a binary number that is sufficiently long (>62 digits).Steps To Reproduce
evaluate the following expression (e.g., in the repl):
(whether the value contains 1's or 0's doesn't matter)
Expected behavior
the number should be parsed correctly, and lix shouldn't crash. the result should be an attribute set
{v = 0;}
nix --version
outputAdditional context
that's undefined behavior in toml11, with theirs report matching this problem two years ago: https://github.com/ToruNiina/toml11/issues/213. we catch it because we run
-fsanitize=undefined
in prod to avoid weird shit happening (as was prevented in this case! cppnix produces{ v = -9223372036854775808; }
forv=0b1000000000000000000000000000000000000000000000000000000000000000
, which is obviously nonsense. add another0
to the binary literal and you get{ v = 0; }
instead, which is even worse)nixpkgs really ought to upgrade toml11. (keeping this bug open because we could in theory override the dependency with a newer version to fix this)
thank you so much for the quick and informative response! <3
do i understand it correctly that providing some sort of error message is therefore not an option as toml11 handles the parsing?
unfortunately yes. our hardening compiler options cause the program to crash hard the moment a problem is detected. in theory the crash is detectable to us, but at that point the program is in a state where we can no longer give reasonable error message to the user (let alone know what caused the crash in the first place) :(
makes sense.
toml11 has no maintainers since november of last year (and its version was never updated anyways), i think i'll look into updating/adopting it as the derivation seems pretty simple even to me as a novice on this field ^^
from what i gathered, https://github.com/NixOS/nixpkgs/pull/394444 will update toml11 as well and i don't know whether i want to file a pr that breaks building nix itself (most likely due to breaking changes in toml11 4.0.0) since i probably lack the expertise to fix that (i know very little c++) and someone else should be investigating: https://github.com/NixOS/nixpkgs/pull/363466
just thought this might be worth to mention, as lix will probably break as well once toml11 4.4.0 is in nixpkgs so it might be worthwhile to override it to not get some surprise breakages down the road, though i don't know anything about the build/development process of lix
don't really know what else to say, but i don't think i can help out much here unfortunately, sorry :(
that's okay. somefew will get around to it eventually :)