[Crash] Lix crashes on nix-instantiate --parse of strings with invalid UTF-8 #1052
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
awaiting
author
awaiting
contributors
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
Feature/S3
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lix-project/lix#1052
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
Lix crashed, while calling
nix-instantiate --parse ./tests/functional/lang/eval-fail-toJSON-non-utf-8.nixof the CppNix repository /tests/functional/lang/eval-fail-toJSON-non-utf-8.nixEffectively, when calling
builtins.toJsonwith a string not conforming to utf-8, it crashesException: nlohmann::json_abi_v3_11_3::detail::type_error: [json.exception.type_error.316] invalid UTF-8 byte at index 16: 0xFF
Stack trace:
0# nix::getStackTraceabi:cxx11 in /nix/store/p89s0as08llbz0v12ph7cyc7v373x97p-lix-2.95.0pre19700101-dev_dirty/lib/liblixutil.so
1# nix::logException(std::basic_string_view<char, std::char_traits >, std::exception const&) in /nix/store/p89s0as08llbz0v12ph7cyc7v373x97p-lix-2.95.0pre19700101-dev_dirty/lib/liblixutil.so
2# 0x00007FFFF7F8EAB4 in /nix/store/p89s0as08llbz0v12ph7cyc7v373x97p-lix-2.95.0pre19700101-dev_dirty/lib/liblixmain.so
3# 0x00007FFFF60BF1AA in /nix/store/dj06r96j515npcqi9d8af1d1c60bx2vn-gcc-14.3.0-lib/lib/libstdc++.so.6
4# std::unexpected() in /nix/store/dj06r96j515npcqi9d8af1d1c60bx2vn-gcc-14.3.0-lib/lib/libstdc++.so.6
5# 0x00007FFFF60BF427 in /nix/store/dj06r96j515npcqi9d8af1d1c60bx2vn-gcc-14.3.0-lib/lib/libstdc++.so.6
6# nlohmann::json_abi_v3_11_3::detail::serializer<nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool, long, unsigned long, double, std::allocator, nix::json::adl_serializer, std::vector<unsigned char, std::allocator >, void> >::dump_escaped(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, bool) in nix-instantiate
7# nlohmann::json_abi_v3_11_3::detail::serializer<nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool, long, unsigned long, double, std::allocator, nix::json::adl_serializer, std::vector<unsigned char, std::allocator >, void> >::dump(nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool, long, unsigned long, double, std::allocator, nix::json::adl_serializer, std::vector<unsigned char, std::allocator >, void> const&, bool, bool, unsigned int, unsigned int) in nix-instantiate
8# nlohmann::json_abi_v3_11_3::detail::serializer<nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool, long, unsigned long, double, std::allocator, nix::json::adl_serializer, std::vector<unsigned char, std::allocator >, void> >::dump(nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool, long, unsigned long, double, std::allocator, nix::json::adl_serializer, std::vector<unsigned char, std::allocator >, void> const&, bool, bool, unsigned int, unsigned int) in nix-instantiate
9# nlohmann::json_abi_v3_11_3::detail::serializer<nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool, long, unsigned long, double, std::allocator, nix::json::adl_serializer, std::vector<unsigned char, std::allocator >, void> >::dump(nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool, long, unsigned long, double, std::allocator, nix::json::adl_serializer, std::vector<unsigned char, std::allocator >, void> const&, bool, bool, unsigned int, unsigned int) in nix-instantiate
10# nlohmann::json_abi_v3_11_3::detail::serializer<nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool, long, unsigned long, double, std::allocator, nix::json::adl_serializer, std::vector<unsigned char, std::allocator >, void> >::dump(nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool, long, unsigned long, double, std::allocator, nix::json::adl_serializer, std::vector<unsigned char, std::allocator >, void> const&, bool, bool, unsigned int, unsigned int) in nix-instantiate
11# nlohmann::json_abi_v3_11_3::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool, long, unsigned long, double, std::allocator, nix::json::adl_serializer, std::vector<unsigned char, std::allocator >, void>::dump(int, char, bool, nlohmann::json_abi_v3_11_3::detail::error_handler_t) const in nix-instantiate
12# 0x000055555580F2A9 in nix-instantiate
13# 0x000055555581122D in nix-instantiate
14# 0x0000555555673DDB in nix-instantiate
15# 0x000055555571C57C in nix-instantiate
16# 0x000055555572093B in nix-instantiate
17# nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::function<int ()>) in /nix/store/p89s0as08llbz0v12ph7cyc7v373x97p-lix-2.95.0pre19700101-dev_dirty/lib/liblixmain.so
18# 0x00005555557201EB in nix-instantiate
19# 0x00007FFFF5C2A47E in /nix/store/g8zyryr9cr6540xsyg4avqkwgxpnwj2a-glibc-2.40-66/lib/libc.so.6
20# __libc_start_main in /nix/store/g8zyryr9cr6540xsyg4avqkwgxpnwj2a-glibc-2.40-66/lib/libc.so.6
21# 0x00005555556377F5 in nix-instantiate
If you have a problem with a specific package or NixOS,
you probably want to file an issue at https://github.com/NixOS/nixpkgs/issues.
Steps To Reproduce
nix-instantiate --parse ./tests/functional/lang/eval-fail-toJSON-non-utf-8.nix(of the cppnix repo, not oursExpected behavior
A clear error message instead of a crash
nix --versionoutput(dev build of feature deprecations, but no change on main)
/nix/store/p89s0as08llbz0v12ph7cyc7v373x97p-lix-2.95.0pre19700101
[Crash] Lix crashes on parsing JSON files with invalid UTF-8to [Crash] Lix crashes onnix-instantiate --parseof strings with invalid UTF-8