NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.54k stars 1.5k forks source link

Segfault when upgrading two outputs of the same derivation installed in the same profile #8514

Open rodrigol-chan opened 1 year ago

rodrigol-chan commented 1 year ago
~ at 15:52:39
$ nix profile install --profile test-profile "nixpkgs/nixos-unstable#mesa^drivers"

~ at 15:53:12
$ nix profile install --profile test-profile "nixpkgs/nixos-unstable#mesa^opencl"

~ at 15:53:17
$ nix profile upgrade --profile test-profile '.*'
[1]    1109005 segmentation fault (core dumped)  nix profile upgrade --profile test-profile '.*'

~ at 15:53:53
139 $ readlink -e $(which nix)
/nix/store/k6ciawnknm1yxxiwm4pih008rijyn9wh-nix-2.15.1/bin/nix

~ at 15:54:05
$ nix --version
nix (Nix) 2.15.1

Running under gdb usually gives me error: basic_string::_M_create but passing -v makes it reproducible under gdb. This is the stack trace:

$ gdb --args /nix/store/k6ciawnknm1yxxiwm4pih008rijyn9wh-nix-2.15.1/bin/nix profile -v upgrade --profile test-profile '.*'
[...]

Thread 1 "nix" received signal SIGSEGV, Segmentation fault.
std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath> >::_M_create_node<nix::StorePath const&> (this=<optimized out>) at /nix/store/2vwipws2crqcjxfzjyq9rjpk61iqf7pf-gcc-12.3.0/include/c++/12.3.0/bits/stl_tree.h:614
warning: Source file is more recent than executable.
614               _M_construct_node(__tmp, std::forward<_Args>(__args)...);
(gdb) bt
#0  std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath> >::_M_create_node<nix::StorePath const&> (this=<optimized out>) at /nix/store/2vwipws2crqcjxfzjyq9rjpk61iqf7pf-gcc-12.3.0/include/c++/12.3.0/bits/stl_tree.h:614
#1  std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath> >::_Alloc_node::operator()<nix::StorePath const&> (__arg=..., this=<synthetic pointer>) at /nix/store/2vwipws2crqcjxfzjyq9rjpk61iqf7pf-gcc-12.3.0/include/c++/12.3.0/bits/stl_tree.h:531
#2  std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath> >::_M_insert_<nix::StorePath const&, std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath> >::_Alloc_node> (
    __node_gen=<synthetic pointer>..., __v=..., __p=0x555555799f48, __x=<optimized out>, this=0x555555799f40) at /nix/store/2vwipws2crqcjxfzjyq9rjpk61iqf7pf-gcc-12.3.0/include/c++/12.3.0/bits/stl_tree.h:1832
#3  std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath> >::_M_insert_unique<nix::StorePath const&> (__v=..., this=0x555555799f40) at /nix/store/2vwipws2crqcjxfzjyq9rjpk61iqf7pf-gcc-12.3.0/include/c++/12.3.0/bits/stl_tree.h:2177
#4  std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath> >::insert (__x=..., this=<optimized out>, this=<optimized out>, __x=...) at /nix/store/2vwipws2crqcjxfzjyq9rjpk61iqf7pf-gcc-12.3.0/include/c++/12.3.0/bits/stl_set.h:512
#5  ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::BuiltPathBuilt const&)#2}::operator()(nix::BuiltPathBuilt const&) const (bfd=..., __closure=<optimized out>) at src/nix/profile.cc:81
#6  std::__invoke_impl<void, nix::overloaded<ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::DerivedPathOpaque const&)#1}, ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::BuiltPathBuilt const&)#2}>, nix::BuiltPathBuilt const&>(std::__invoke_other, nix::overloaded<ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::DerivedPathOpaque const&)#1}, ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::BuiltPathBuilt const&)#2}>&&, nix::BuiltPathBuilt const&) (__f=...) at /nix/store/2vwipws2crqcjxfzjyq9rjpk61iqf7pf-gcc-12.3.0/include/c++/12.3.0/bits/invoke.h:61
#7  std::__invoke<nix::overloaded<ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::DerivedPathOpaque const&)#1}, ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::BuiltPathBuilt const&)#2}>, nix::BuiltPathBuilt const&>(nix::overloaded<ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::DerivedPathOpaque const&)#1}, ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::BuiltPathBuilt const&)#2}>&&, nix::BuiltPathBuilt const&) (__fn=...) at /nix/store/2vwipws2crqcjxfzjyq9rjpk61iqf7pf-gcc-12.3.0/include/c++/12.3.0/bits/invoke.h:96
#8  std::__detail::__variant::__gen_vtable_impl<std::__detail::__variant::_Multi_array<std::__detail::__variant::__deduce_visit_result<void> (*)(nix::overloaded<ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::DerivedPathOpaque const&)#1}, ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::BuiltPathBuilt const&)#2}>&&, std::variant<nix::DerivedPathOpaque, nix::BuiltPathBuilt> const&)>, std::integer_sequence<unsigned long, 1ul> >::__visit_invoke(nix::overloaded<ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::DerivedPathOpaque const&)#1}, ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::BuiltPathBuilt const&)#2}>&&, std::variant<nix::DerivedPathOpaque, nix::BuiltPathBuilt> const&) (__vars#0=..., __visitor=...) at /nix/store/2vwipws2crqcjxfzjyq9rjpk61iqf7pf-gcc-12.3.0/include/c++/12.3.0/variant:1031
#9  std::__do_visit<std::__detail::__variant::__deduce_visit_result<void>, nix::overloaded<ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::DerivedPathOpaque const&)#1}, ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::BuiltPathBuilt const&)#2}>, std::variant<nix::DerivedPathOpaque, nix::BuiltPathBuilt> const&>(nix::overloaded<ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::DerivedPathOpaque const&)#1}, ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::BuiltPathBuilt const&)#2}>&&, std::variant<nix::DerivedPathOpaque, nix::BuiltPathBuilt> const&) (__visitor=...)
    at /nix/store/2vwipws2crqcjxfzjyq9rjpk61iqf7pf-gcc-12.3.0/include/c++/12.3.0/variant:1791
#10 std::visit<nix::overloaded<ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::DerivedPathOpaque const&)#1}, ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::BuiltPathBuilt const&)#2}>, std::variant<nix::DerivedPathOpaque, nix::BuiltPathBuilt> const&>(nix::overloaded<ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::DerivedPathOpaque const&)#1}, ProfileElement::updateStorePaths(nix::ref<nix::Store>, nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath> > const&)::{lambda(nix::BuiltPathBuilt const&)#2}>&&, std::variant<nix::DerivedPathOpaque, nix::BuiltPathBuilt> const&) (__visitor=...) at /nix/store/2vwipws2crqcjxfzjyq9rjpk61iqf7pf-gcc-12.3.0/include/c++/12.3.0/variant:1853
#11 ProfileElement::updateStorePaths (evalStore=..., store=..., builtPaths=..., this=0x555555799f40) at src/nix/profile.cc:75
#12 CmdProfileUpgrade::run (this=0x5555557a0c00, store=...) at src/nix/profile.cc:599
#13 0x00007ffff7ac6db7 in nix::StoreCommand::run (this=0x5555557a0f08) at src/libcmd/command.cc:55
#14 0x000055555568114e in nix::mainWrapped (argc=7, argv=<optimized out>) at src/nix/main.cc:461
#15 0x00007ffff7be2fa1 in std::function<void ()>::operator()() const (this=<optimized out>, this=<optimized out>) at /nix/store/2vwipws2crqcjxfzjyq9rjpk61iqf7pf-gcc-12.3.0/include/c++/12.3.0/bits/std_function.h:591
#16 nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<void ()>) (programName="/nix/store/k6ciawnknm1yxxiwm4pih008rijyn9wh-nix-2.15.1/bin/nix", fun=...) at src/libmain/shared.cc:400
#17 0x00005555555de2a7 in main (argc=<optimized out>, argv=<optimized out>) at src/nix/main.cc:472
nixos-discourse commented 1 year ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-06-16-nix-team-meeting-minutes-63/29316/1

nixos-discourse commented 3 weeks ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-09-25-nix-team-meeting-minutes-181-180/52712/1