UAF in nix copy #618

Open
opened 2025-01-08 08:06:27 +00:00 by martinetd · 1 comment

Describe the bug

nix copy crashes randomly on large copies (a couple of files copy just fine)

Running with ASAN yields this trace, on 3413ab5629 (today's main) (originally crashed on nixos 24.11's lix, 2.91.1)

nix copy --impure --to /mnt/scratch/tmp?trusted=yes .#nixosConfigurations.mymachine.config.system.build.toplevel
warning: Git tree '/etc/nixos' is dirty
[0 copied (0.0/0.3 MiB)] copying 1692 paths=================================================================
error (ignored): error: interrupted by the user
==3187895==ERROR: AddressSanitizer: heap-use-after-free on address 0x50600b32b0a8 at pc 0x58773821b691 bp 0x73e9f629ec80 sp 0x73e9f629ec78
READ of size 8 at 0x50600b32b0a8 thread T14
error (ignored): error: interrupted by the user
error (ignored): error: interrupted by the user
error (ignored): error: cannot add path '/nix/store/0fysmis4gdx6zmkj81wz3j8q4p61v272-unit-gpg-agent.socket' because it lacks a signature by a trusted key
error (ignored): error: interrupted by the user
error (ignored): error: interrupted by the user
error (ignored): error: interrupted by the user
[4/0/1692 copied (1 failed) (1.9/68.6 MiB)] copying 1692 paths    #0 0x58773821b690 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::size() const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/basic_string.h:1072:16
    #1 0x58773821b690 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::compare(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/basic_string.h:3186:34
    #2 0x58773821b690 in decltype(__detail::__char_traits_cmp_cat<std::char_traits<char>>(0)) std::operator<=><char, std::char_traits<char>, std::allocator<char>>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/basic_string.h:3748:61
    #3 0x58773821b690 in nix::StorePath::operator<(nix::StorePath const&) const /home/myuser/lix/build/lix/libstore/path.hh:46:25
    #4 0x58773821b690 in std::less<nix::StorePath>::operator()(nix::StorePath const&, nix::StorePath const&) const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_function.h:408:20
    #5 0x58773821b690 in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_get_insert_unique_pos(nix::StorePath const&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:2118:13
    #6 0x5877382db27b in std::pair<std::_Rb_tree_iterator<nix::StorePath>, bool> 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&>(nix::StorePath const&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:2171:4
    #7 0x73ea2df68684 in std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::insert(nix::StorePath const&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_set.h:514:9
    #8 0x73ea2df68684 in void nix::processGraph<nix::StorePath>(nix::ThreadPool&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, std::function<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> (nix::StorePath const&)>, std::function<void (nix::StorePath const&)>)::'lambda'(nix::StorePath const&)::operator()(nix::StorePath const&) const /home/myuser/lix/build/lix/libutil/thread-pool.hh:122:43
    #9 0x73ea2e6b8aff in std::function<void ()>::operator()() const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/std_function.h:591:9
    #10 0x73ea2e6b8aff in nix::ThreadPool::doWork(bool) /home/myuser/lix/build/lix/libutil/thread-pool.cc:161:13
    #11 0x73ea2c8e86d2 in execute_native_thread_routine (/nix/store/ybjcla5bhj8g1y84998pn4a2drfxybkv-gcc-13.3.0-lib/lib/libstdc++.so.6+0xe86d2)
    #12 0x73ea2ec9cc14 in asan_thread_start(void*) (/nix/store/03bq5hc45d5wkw8pajmz4vgd5s0ivyq8-clang-wrapper-18.1.8/resource-root/lib/linux/libclang_rt.asan-x86_64.so+0x9cc14)
    #13 0x73ea2c697d01 in start_thread (/nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6+0x90d01) (BuildId: 5c3f64ce109fb7a0be214b5e31d2a4e7d3f94fff)
    #14 0x73ea2c7173ab in __GI___clone3 (/nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6+0x1103ab) (BuildId: 5c3f64ce109fb7a0be214b5e31d2a4e7d3f94fff)

0x50600b32b0a8 is located 40 bytes inside of 64-byte region [0x50600b32b080,0x50600b32b0c0)
freed by thread T0 here:
    #0 0x73ea2ed73be0 in operator delete(void*) (/nix/store/03bq5hc45d5wkw8pajmz4vgd5s0ivyq8-clang-wrapper-18.1.8/resource-root/lib/linux/libclang_rt.asan-x86_64.so+0x173be0)
    #1 0x58773815910c in std::__new_allocator<std::_Rb_tree_node<nix::StorePath>>::deallocate(std::_Rb_tree_node<nix::StorePath>*, unsigned long) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/new_allocator.h:172:2
    #2 0x58773815910c in std::allocator<std::_Rb_tree_node<nix::StorePath>>::deallocate(std::_Rb_tree_node<nix::StorePath>*, unsigned long) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/allocator.h:210:25
    #3 0x58773815910c in std::allocator_traits<std::allocator<std::_Rb_tree_node<nix::StorePath>>>::deallocate(std::allocator<std::_Rb_tree_node<nix::StorePath>>&, std::_Rb_tree_node<nix::StorePath>*, unsigned long) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/alloc_traits.h:517:13
    #4 0x58773815910c in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_put_node(std::_Rb_tree_node<nix::StorePath>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:567:9
    #5 0x58773815910c in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_drop_node(std::_Rb_tree_node<nix::StorePath>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:634:2
    #6 0x58773815910c in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_erase(std::_Rb_tree_node<nix::StorePath>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1938:4
    #7 0x587738159134 in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_erase(std::_Rb_tree_node<nix::StorePath>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4
    #8 0x587738159134 in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_erase(std::_Rb_tree_node<nix::StorePath>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4
    #9 0x587738159134 in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_erase(std::_Rb_tree_node<nix::StorePath>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4
    #10 0x587738159134 in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_erase(std::_Rb_tree_node<nix::StorePath>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4
    #11 0x587738159134 in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_erase(std::_Rb_tree_node<nix::StorePath>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4
    #12 0x73ea2dd38977 in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::~_Rb_tree() /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:986:9
    #13 0x73ea2dd38977 in std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::~set() /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_set.h:283:22
    #14 0x73ea2dd38977 in std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>::~pair() /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_iterator.h:2992:12
    #15 0x73ea2dd38977 in void std::destroy_at<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>(std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_construct.h:88:15
    #16 0x73ea2dd38977 in void std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>>::destroy<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>(std::allocator<std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>&, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/alloc_traits.h:560:4
    #17 0x73ea2dd38977 in std::_Rb_tree<nix::StorePath, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>, std::_Select1st<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::_M_destroy_node(std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:625:2
    #18 0x73ea2dd38977 in std::_Rb_tree<nix::StorePath, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>, std::_Select1st<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::_M_drop_node(std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:633:2
    #19 0x73ea2dd38977 in std::_Rb_tree<nix::StorePath, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>, std::_Select1st<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::_M_erase(std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1938:4
    #20 0x73ea2dd3893c in std::_Rb_tree<nix::StorePath, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>, std::_Select1st<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::_M_erase(std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4
    #21 0x73ea2dd3893c in std::_Rb_tree<nix::StorePath, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>, std::_Select1st<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::_M_erase(std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4
    #22 0x73ea2dd3893c in std::_Rb_tree<nix::StorePath, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>, std::_Select1st<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::_M_erase(std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4
    #23 0x73ea2dd3893c in std::_Rb_tree<nix::StorePath, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>, std::_Select1st<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::_M_erase(std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4
    #24 0x73ea2df67d71 in std::_Rb_tree<nix::StorePath, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>, std::_Select1st<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::~_Rb_tree() /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:986:9
    #25 0x73ea2df67d71 in std::map<nix::StorePath, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::~map() /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_map.h:314:22
    #26 0x73ea2df67d71 in void nix::processGraph<nix::StorePath>(nix::ThreadPool&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, std::function<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> (nix::StorePath const&)>, std::function<void (nix::StorePath const&)>)::Graph::~Graph() /home/myuser/lix/build/lix/libutil/thread-pool.hh:93:12
    #27 0x73ea2df67d71 in nix::Sync<void nix::processGraph<nix::StorePath>(nix::ThreadPool&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, std::function<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> (nix::StorePath const&)>, std::function<void (nix::StorePath const&)>)::Graph, std::mutex>::~Sync() /home/myuser/lix/build/lix/libutil/sync.hh:28:7
    #28 0x73ea2df5fa41 in void nix::processGraph<nix::StorePath>(nix::ThreadPool&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, std::function<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> (nix::StorePath const&)>, std::function<void (nix::StorePath const&)>) /home/myuser/lix/build/lix/libutil/thread-pool.hh:159:1
    #29 0x73ea2df3249c in nix::Store::addMultipleToStore(std::vector<std::pair<nix::ValidPathInfo, std::unique_ptr<nix::Source, std::default_delete<nix::Source>>>, std::allocator<std::pair<nix::ValidPathInfo, std::unique_ptr<nix::Source, std::default_delete<nix::Source>>>>>&, nix::Activity&, nix::RepairFlag, nix::CheckSigsFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:311:5
    #30 0x73ea2df4d2dd in nix::copyPaths(nix::Store&, nix::Store&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, nix::RepairFlag, nix::CheckSigsFlag, nix::SubstituteFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:1259:14
    #31 0x73ea2df4ae5d in nix::copyPaths(nix::Store&, nix::Store&, std::set<nix::RealisedPath, std::less<nix::RealisedPath>, std::allocator<nix::RealisedPath>> const&, nix::RepairFlag, nix::CheckSigsFlag, nix::SubstituteFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:1138:21
    #32 0x5877381b1188 in CmdCopy::run(nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath>>&&) /home/myuser/lix/build/lix/nix/copy.cc:57:9
    #33 0x73ea2e938ee1 in nix::BuiltPathsCommand::run(nix::ref<nix::Store>, std::vector<nix::ref<nix::Installable>, std::allocator<nix::ref<nix::Installable>>>&&) /home/myuser/lix/build/lix/libcmd/command.cc:180:5
    #34 0x73ea2e9c2dae in nix::InstallablesCommand::run(nix::ref<nix::Store>, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&&) /home/myuser/lix/build/lix/libcmd/installables.cc:846:5
    #35 0x73ea2e9c18e5 in nix::RawInstallablesCommand::run(nix::ref<nix::Store>) /home/myuser/lix/build/lix/libcmd/installables.cc:831:5
    #36 0x73ea2e9320bb in nix::StoreCommand::run() /home/myuser/lix/build/lix/libcmd/command.cc:49:5
    #37 0x58773831e1fe in nix::mainWrapped(int, char**) /home/myuser/lix/build/lix/nix/main.cc:529:10
    #38 0x73ea2d9d1f54 in std::function<void ()>::operator()() const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/std_function.h:591:9
    #39 0x73ea2d9d1f54 in nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::function<void ()>) /home/myuser/lix/build/lix/libmain/shared.cc:311:9
    #40 0x587738322687 in main /home/myuser/lix/build/lix/nix/main.cc:545:12
    #41 0x73ea2c63127d in __libc_start_call_main (/nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6+0x2a27d) (BuildId: 5c3f64ce109fb7a0be214b5e31d2a4e7d3f94fff)

previously allocated by thread T11 here:
    #0 0x73ea2ed73108 in operator new(unsigned long) (/nix/store/03bq5hc45d5wkw8pajmz4vgd5s0ivyq8-clang-wrapper-18.1.8/resource-root/lib/linux/libclang_rt.asan-x86_64.so+0x173108)
    #1 0x5877382db362 in std::__new_allocator<std::_Rb_tree_node<nix::StorePath>>::allocate(unsigned long, void const*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/new_allocator.h:151:27
    #2 0x5877382db362 in std::allocator<std::_Rb_tree_node<nix::StorePath>>::allocate(unsigned long) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/allocator.h:198:32
    #3 0x5877382db362 in std::allocator_traits<std::allocator<std::_Rb_tree_node<nix::StorePath>>>::allocate(std::allocator<std::_Rb_tree_node<nix::StorePath>>&, unsigned long) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/alloc_traits.h:482:20
    #4 0x5877382db362 in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_get_node() /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:563:16
    #5 0x5877382db362 in std::_Rb_tree_node<nix::StorePath>* 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&>(nix::StorePath const&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:613:23
    #6 0x5877382db362 in std::_Rb_tree_node<nix::StorePath>* 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&>(nix::StorePath const&) const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:531:18
    #7 0x5877382db362 in std::_Rb_tree_iterator<nix::StorePath> 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>(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, nix::StorePath const&, std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_Alloc_node&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1831:19
    #8 0x5877382db362 in std::pair<std::_Rb_tree_iterator<nix::StorePath>, bool> 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&>(nix::StorePath const&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:2176:16
    #9 0x73ea2df68684 in std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::insert(nix::StorePath const&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_set.h:514:9
    #10 0x73ea2df68684 in void nix::processGraph<nix::StorePath>(nix::ThreadPool&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, std::function<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> (nix::StorePath const&)>, std::function<void (nix::StorePath const&)>)::'lambda'(nix::StorePath const&)::operator()(nix::StorePath const&) const /home/myuser/lix/build/lix/libutil/thread-pool.hh:122:43
    #11 0x73ea2e6b8aff in std::function<void ()>::operator()() const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/std_function.h:591:9
    #12 0x73ea2e6b8aff in nix::ThreadPool::doWork(bool) /home/myuser/lix/build/lix/libutil/thread-pool.cc:161:13
    #13 0x73ea2c8e86d2 in execute_native_thread_routine (/nix/store/ybjcla5bhj8g1y84998pn4a2drfxybkv-gcc-13.3.0-lib/lib/libstdc++.so.6+0xe86d2)

Thread T14 created by T0 here:
    #0 0x73ea2ed59ecd in pthread_create (/nix/store/03bq5hc45d5wkw8pajmz4vgd5s0ivyq8-clang-wrapper-18.1.8/resource-root/lib/linux/libclang_rt.asan-x86_64.so+0x159ecd)
    #1 0x73ea2c8e87a8 in std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>, void (*)()) (/nix/store/ybjcla5bhj8g1y84998pn4a2drfxybkv-gcc-13.3.0-lib/lib/libstdc++.so.6+0xe87a8)
    #2 0x73ea2e6b8038 in nix::ThreadPool::enqueue(std::function<void ()> const&) /home/myuser/lix/build/lix/libutil/thread-pool.cc:51:24
    #3 0x73ea2df5f5be in void nix::processGraph<nix::StorePath>(nix::ThreadPool&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, std::function<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> (nix::StorePath const&)>, std::function<void (nix::StorePath const&)>) /home/myuser/lix/build/lix/libutil/thread-pool.hh:153:14
    #4 0x73ea2df3249c in nix::Store::addMultipleToStore(std::vector<std::pair<nix::ValidPathInfo, std::unique_ptr<nix::Source, std::default_delete<nix::Source>>>, std::allocator<std::pair<nix::ValidPathInfo, std::unique_ptr<nix::Source, std::default_delete<nix::Source>>>>>&, nix::Activity&, nix::RepairFlag, nix::CheckSigsFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:311:5
    #5 0x73ea2df4d2dd in nix::copyPaths(nix::Store&, nix::Store&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, nix::RepairFlag, nix::CheckSigsFlag, nix::SubstituteFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:1259:14
    #6 0x73ea2df4ae5d in nix::copyPaths(nix::Store&, nix::Store&, std::set<nix::RealisedPath, std::less<nix::RealisedPath>, std::allocator<nix::RealisedPath>> const&, nix::RepairFlag, nix::CheckSigsFlag, nix::SubstituteFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:1138:21
    #7 0x5877381b1188 in CmdCopy::run(nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath>>&&) /home/myuser/lix/build/lix/nix/copy.cc:57:9
    #8 0x73ea2e938ee1 in nix::BuiltPathsCommand::run(nix::ref<nix::Store>, std::vector<nix::ref<nix::Installable>, std::allocator<nix::ref<nix::Installable>>>&&) /home/myuser/lix/build/lix/libcmd/command.cc:180:5
    #9 0x73ea2e9c2dae in nix::InstallablesCommand::run(nix::ref<nix::Store>, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&&) /home/myuser/lix/build/lix/libcmd/installables.cc:846:5
    #10 0x73ea2e9c18e5 in nix::RawInstallablesCommand::run(nix::ref<nix::Store>) /home/myuser/lix/build/lix/libcmd/installables.cc:831:5
    #11 0x73ea2e9320bb in nix::StoreCommand::run() /home/myuser/lix/build/lix/libcmd/command.cc:49:5
    #12 0x58773831e1fe in nix::mainWrapped(int, char**) /home/myuser/lix/build/lix/nix/main.cc:529:10
    #13 0x73ea2d9d1f54 in std::function<void ()>::operator()() const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/std_function.h:591:9
    #14 0x73ea2d9d1f54 in nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::function<void ()>) /home/myuser/lix/build/lix/libmain/shared.cc:311:9
    #15 0x587738322687 in main /home/myuser/lix/build/lix/nix/main.cc:545:12
    #16 0x73ea2c63127d in __libc_start_call_main (/nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6+0x2a27d) (BuildId: 5c3f64ce109fb7a0be214b5e31d2a4e7d3f94fff)

Thread T11 created by T0 here:
    #0 0x73ea2ed59ecd in pthread_create (/nix/store/03bq5hc45d5wkw8pajmz4vgd5s0ivyq8-clang-wrapper-18.1.8/resource-root/lib/linux/libclang_rt.asan-x86_64.so+0x159ecd)
    #1 0x73ea2c8e87a8 in std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>, void (*)()) (/nix/store/ybjcla5bhj8g1y84998pn4a2drfxybkv-gcc-13.3.0-lib/lib/libstdc++.so.6+0xe87a8)
    #2 0x73ea2e6ba01a in std::thread& std::vector<std::thread, std::allocator<std::thread>>::emplace_back<void (nix::ThreadPool::*)(bool), nix::ThreadPool*, bool>(void (nix::ThreadPool::*&&)(bool), nix::ThreadPool*&&, bool&&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/vector.tcc:123:4
    #3 0x73ea2e6b8038 in nix::ThreadPool::enqueue(std::function<void ()> const&) /home/myuser/lix/build/lix/libutil/thread-pool.cc:51:24
    #4 0x73ea2df5f5be in void nix::processGraph<nix::StorePath>(nix::ThreadPool&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, std::function<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> (nix::StorePath const&)>, std::function<void (nix::StorePath const&)>) /home/myuser/lix/build/lix/libutil/thread-pool.hh:153:14
    #5 0x73ea2df3249c in nix::Store::addMultipleToStore(std::vector<std::pair<nix::ValidPathInfo, std::unique_ptr<nix::Source, std::default_delete<nix::Source>>>, std::allocator<std::pair<nix::ValidPathInfo, std::unique_ptr<nix::Source, std::default_delete<nix::Source>>>>>&, nix::Activity&, nix::RepairFlag, nix::CheckSigsFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:311:5
    #6 0x73ea2df4d2dd in nix::copyPaths(nix::Store&, nix::Store&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, nix::RepairFlag, nix::CheckSigsFlag, nix::SubstituteFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:1259:14
    #7 0x73ea2df4ae5d in nix::copyPaths(nix::Store&, nix::Store&, std::set<nix::RealisedPath, std::less<nix::RealisedPath>, std::allocator<nix::RealisedPath>> const&, nix::RepairFlag, nix::CheckSigsFlag, nix::SubstituteFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:1138:21
    #8 0x5877381b1188 in CmdCopy::run(nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath>>&&) /home/myuser/lix/build/lix/nix/copy.cc:57:9
    #9 0x73ea2e938ee1 in nix::BuiltPathsCommand::run(nix::ref<nix::Store>, std::vector<nix::ref<nix::Installable>, std::allocator<nix::ref<nix::Installable>>>&&) /home/myuser/lix/build/lix/libcmd/command.cc:180:5
    #10 0x73ea2e9c2dae in nix::InstallablesCommand::run(nix::ref<nix::Store>, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&&) /home/myuser/lix/build/lix/libcmd/installables.cc:846:5
    #11 0x73ea2e9c18e5 in nix::RawInstallablesCommand::run(nix::ref<nix::Store>) /home/myuser/lix/build/lix/libcmd/installables.cc:831:5
    #12 0x73ea2e9320bb in nix::StoreCommand::run() /home/myuser/lix/build/lix/libcmd/command.cc:49:5
    #13 0x58773831e1fe in nix::mainWrapped(int, char**) /home/myuser/lix/build/lix/nix/main.cc:529:10
    #14 0x73ea2d9d1f54 in std::function<void ()>::operator()() const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/std_function.h:591:9
    #15 0x73ea2d9d1f54 in nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::function<void ()>) /home/myuser/lix/build/lix/libmain/shared.cc:311:9
    #16 0x587738322687 in main /home/myuser/lix/build/lix/nix/main.cc:545:12
    #17 0x73ea2c63127d in __libc_start_call_main (/nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6+0x2a27d) (BuildId: 5c3f64ce109fb7a0be214b5e31d2a4e7d3f94fff)

SUMMARY: AddressSanitizer: heap-use-after-free /home/myuser/lix/build/lix/libstore/path.hh:46:25 in nix::StorePath::operator<(nix::StorePath const&) const
Shadow bytes around the buggy address:
  0x50600b32ae00: fd fd fd fd fa fa fa fa fd fd fd fd fd fd fd fd
  0x50600b32ae80: fa fa fa fa fd fd fd fd fd fd fd fd fa fa fa fa
  0x50600b32af00: fd fd fd fd fd fd fd fd fa fa fa fa fd fd fd fd
  0x50600b32af80: fd fd fd fd fa fa fa fa fd fd fd fd fd fd fd fd
  0x50600b32b000: fa fa fa fa fd fd fd fd fd fd fd fd fa fa fa fa
=>0x50600b32b080: fd fd fd fd fd[fd]fd fd fa fa fa fa fd fd fd fd
  0x50600b32b100: fd fd fd fd fa fa fa fa fd fd fd fd fd fd fd fd
  0x50600b32b180: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa
  0x50600b32b200: fd fd fd fd fd fd fd fd fa fa fa fa fd fd fd fd
  0x50600b32b280: fd fd fd fd fa fa fa fa 00 00 00 00 00 00 00 00
  0x50600b32b300: fa fa fa fa 00 00 00 00 00 00 00 00 fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==3187895==ABORTING

Steps To Reproduce

  1. find some flake-based system config
  2. run nix copy to some random directory, or ssh, or anything as above.
  3. observe crashes

Expected behavior

Shouldn't crash.

nix --version output

reproduced on 3413ab5629 (today's main) and nixos 24.11's lix, 2.91.1

Additional context

None at this time.

## Describe the bug `nix copy` crashes randomly on large copies (a couple of files copy just fine) Running with ASAN yields this trace, on 3413ab56292f12ac03ee49270bcaf16038020cb3 (today's main) (originally crashed on nixos 24.11's lix, 2.91.1) ``` nix copy --impure --to /mnt/scratch/tmp?trusted=yes .#nixosConfigurations.mymachine.config.system.build.toplevel warning: Git tree '/etc/nixos' is dirty [0 copied (0.0/0.3 MiB)] copying 1692 paths================================================================= error (ignored): error: interrupted by the user ==3187895==ERROR: AddressSanitizer: heap-use-after-free on address 0x50600b32b0a8 at pc 0x58773821b691 bp 0x73e9f629ec80 sp 0x73e9f629ec78 READ of size 8 at 0x50600b32b0a8 thread T14 error (ignored): error: interrupted by the user error (ignored): error: interrupted by the user error (ignored): error: cannot add path '/nix/store/0fysmis4gdx6zmkj81wz3j8q4p61v272-unit-gpg-agent.socket' because it lacks a signature by a trusted key error (ignored): error: interrupted by the user error (ignored): error: interrupted by the user error (ignored): error: interrupted by the user [4/0/1692 copied (1 failed) (1.9/68.6 MiB)] copying 1692 paths #0 0x58773821b690 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::size() const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/basic_string.h:1072:16 #1 0x58773821b690 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::compare(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/basic_string.h:3186:34 #2 0x58773821b690 in decltype(__detail::__char_traits_cmp_cat<std::char_traits<char>>(0)) std::operator<=><char, std::char_traits<char>, std::allocator<char>>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/basic_string.h:3748:61 #3 0x58773821b690 in nix::StorePath::operator<(nix::StorePath const&) const /home/myuser/lix/build/lix/libstore/path.hh:46:25 #4 0x58773821b690 in std::less<nix::StorePath>::operator()(nix::StorePath const&, nix::StorePath const&) const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_function.h:408:20 #5 0x58773821b690 in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_get_insert_unique_pos(nix::StorePath const&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:2118:13 #6 0x5877382db27b in std::pair<std::_Rb_tree_iterator<nix::StorePath>, bool> 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&>(nix::StorePath const&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:2171:4 #7 0x73ea2df68684 in std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::insert(nix::StorePath const&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_set.h:514:9 #8 0x73ea2df68684 in void nix::processGraph<nix::StorePath>(nix::ThreadPool&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, std::function<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> (nix::StorePath const&)>, std::function<void (nix::StorePath const&)>)::'lambda'(nix::StorePath const&)::operator()(nix::StorePath const&) const /home/myuser/lix/build/lix/libutil/thread-pool.hh:122:43 #9 0x73ea2e6b8aff in std::function<void ()>::operator()() const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/std_function.h:591:9 #10 0x73ea2e6b8aff in nix::ThreadPool::doWork(bool) /home/myuser/lix/build/lix/libutil/thread-pool.cc:161:13 #11 0x73ea2c8e86d2 in execute_native_thread_routine (/nix/store/ybjcla5bhj8g1y84998pn4a2drfxybkv-gcc-13.3.0-lib/lib/libstdc++.so.6+0xe86d2) #12 0x73ea2ec9cc14 in asan_thread_start(void*) (/nix/store/03bq5hc45d5wkw8pajmz4vgd5s0ivyq8-clang-wrapper-18.1.8/resource-root/lib/linux/libclang_rt.asan-x86_64.so+0x9cc14) #13 0x73ea2c697d01 in start_thread (/nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6+0x90d01) (BuildId: 5c3f64ce109fb7a0be214b5e31d2a4e7d3f94fff) #14 0x73ea2c7173ab in __GI___clone3 (/nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6+0x1103ab) (BuildId: 5c3f64ce109fb7a0be214b5e31d2a4e7d3f94fff) 0x50600b32b0a8 is located 40 bytes inside of 64-byte region [0x50600b32b080,0x50600b32b0c0) freed by thread T0 here: #0 0x73ea2ed73be0 in operator delete(void*) (/nix/store/03bq5hc45d5wkw8pajmz4vgd5s0ivyq8-clang-wrapper-18.1.8/resource-root/lib/linux/libclang_rt.asan-x86_64.so+0x173be0) #1 0x58773815910c in std::__new_allocator<std::_Rb_tree_node<nix::StorePath>>::deallocate(std::_Rb_tree_node<nix::StorePath>*, unsigned long) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/new_allocator.h:172:2 #2 0x58773815910c in std::allocator<std::_Rb_tree_node<nix::StorePath>>::deallocate(std::_Rb_tree_node<nix::StorePath>*, unsigned long) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/allocator.h:210:25 #3 0x58773815910c in std::allocator_traits<std::allocator<std::_Rb_tree_node<nix::StorePath>>>::deallocate(std::allocator<std::_Rb_tree_node<nix::StorePath>>&, std::_Rb_tree_node<nix::StorePath>*, unsigned long) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/alloc_traits.h:517:13 #4 0x58773815910c in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_put_node(std::_Rb_tree_node<nix::StorePath>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:567:9 #5 0x58773815910c in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_drop_node(std::_Rb_tree_node<nix::StorePath>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:634:2 #6 0x58773815910c in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_erase(std::_Rb_tree_node<nix::StorePath>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1938:4 #7 0x587738159134 in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_erase(std::_Rb_tree_node<nix::StorePath>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4 #8 0x587738159134 in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_erase(std::_Rb_tree_node<nix::StorePath>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4 #9 0x587738159134 in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_erase(std::_Rb_tree_node<nix::StorePath>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4 #10 0x587738159134 in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_erase(std::_Rb_tree_node<nix::StorePath>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4 #11 0x587738159134 in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_erase(std::_Rb_tree_node<nix::StorePath>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4 #12 0x73ea2dd38977 in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::~_Rb_tree() /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:986:9 #13 0x73ea2dd38977 in std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::~set() /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_set.h:283:22 #14 0x73ea2dd38977 in std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>::~pair() /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_iterator.h:2992:12 #15 0x73ea2dd38977 in void std::destroy_at<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>(std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_construct.h:88:15 #16 0x73ea2dd38977 in void std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>>::destroy<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>(std::allocator<std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>&, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/alloc_traits.h:560:4 #17 0x73ea2dd38977 in std::_Rb_tree<nix::StorePath, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>, std::_Select1st<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::_M_destroy_node(std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:625:2 #18 0x73ea2dd38977 in std::_Rb_tree<nix::StorePath, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>, std::_Select1st<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::_M_drop_node(std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:633:2 #19 0x73ea2dd38977 in std::_Rb_tree<nix::StorePath, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>, std::_Select1st<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::_M_erase(std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1938:4 #20 0x73ea2dd3893c in std::_Rb_tree<nix::StorePath, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>, std::_Select1st<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::_M_erase(std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4 #21 0x73ea2dd3893c in std::_Rb_tree<nix::StorePath, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>, std::_Select1st<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::_M_erase(std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4 #22 0x73ea2dd3893c in std::_Rb_tree<nix::StorePath, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>, std::_Select1st<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::_M_erase(std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4 #23 0x73ea2dd3893c in std::_Rb_tree<nix::StorePath, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>, std::_Select1st<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::_M_erase(std::_Rb_tree_node<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1936:4 #24 0x73ea2df67d71 in std::_Rb_tree<nix::StorePath, std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>, std::_Select1st<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::~_Rb_tree() /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:986:9 #25 0x73ea2df67d71 in std::map<nix::StorePath, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>, std::less<nix::StorePath>, std::allocator<std::pair<nix::StorePath const, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>>>>::~map() /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_map.h:314:22 #26 0x73ea2df67d71 in void nix::processGraph<nix::StorePath>(nix::ThreadPool&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, std::function<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> (nix::StorePath const&)>, std::function<void (nix::StorePath const&)>)::Graph::~Graph() /home/myuser/lix/build/lix/libutil/thread-pool.hh:93:12 #27 0x73ea2df67d71 in nix::Sync<void nix::processGraph<nix::StorePath>(nix::ThreadPool&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, std::function<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> (nix::StorePath const&)>, std::function<void (nix::StorePath const&)>)::Graph, std::mutex>::~Sync() /home/myuser/lix/build/lix/libutil/sync.hh:28:7 #28 0x73ea2df5fa41 in void nix::processGraph<nix::StorePath>(nix::ThreadPool&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, std::function<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> (nix::StorePath const&)>, std::function<void (nix::StorePath const&)>) /home/myuser/lix/build/lix/libutil/thread-pool.hh:159:1 #29 0x73ea2df3249c in nix::Store::addMultipleToStore(std::vector<std::pair<nix::ValidPathInfo, std::unique_ptr<nix::Source, std::default_delete<nix::Source>>>, std::allocator<std::pair<nix::ValidPathInfo, std::unique_ptr<nix::Source, std::default_delete<nix::Source>>>>>&, nix::Activity&, nix::RepairFlag, nix::CheckSigsFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:311:5 #30 0x73ea2df4d2dd in nix::copyPaths(nix::Store&, nix::Store&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, nix::RepairFlag, nix::CheckSigsFlag, nix::SubstituteFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:1259:14 #31 0x73ea2df4ae5d in nix::copyPaths(nix::Store&, nix::Store&, std::set<nix::RealisedPath, std::less<nix::RealisedPath>, std::allocator<nix::RealisedPath>> const&, nix::RepairFlag, nix::CheckSigsFlag, nix::SubstituteFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:1138:21 #32 0x5877381b1188 in CmdCopy::run(nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath>>&&) /home/myuser/lix/build/lix/nix/copy.cc:57:9 #33 0x73ea2e938ee1 in nix::BuiltPathsCommand::run(nix::ref<nix::Store>, std::vector<nix::ref<nix::Installable>, std::allocator<nix::ref<nix::Installable>>>&&) /home/myuser/lix/build/lix/libcmd/command.cc:180:5 #34 0x73ea2e9c2dae in nix::InstallablesCommand::run(nix::ref<nix::Store>, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&&) /home/myuser/lix/build/lix/libcmd/installables.cc:846:5 #35 0x73ea2e9c18e5 in nix::RawInstallablesCommand::run(nix::ref<nix::Store>) /home/myuser/lix/build/lix/libcmd/installables.cc:831:5 #36 0x73ea2e9320bb in nix::StoreCommand::run() /home/myuser/lix/build/lix/libcmd/command.cc:49:5 #37 0x58773831e1fe in nix::mainWrapped(int, char**) /home/myuser/lix/build/lix/nix/main.cc:529:10 #38 0x73ea2d9d1f54 in std::function<void ()>::operator()() const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/std_function.h:591:9 #39 0x73ea2d9d1f54 in nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::function<void ()>) /home/myuser/lix/build/lix/libmain/shared.cc:311:9 #40 0x587738322687 in main /home/myuser/lix/build/lix/nix/main.cc:545:12 #41 0x73ea2c63127d in __libc_start_call_main (/nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6+0x2a27d) (BuildId: 5c3f64ce109fb7a0be214b5e31d2a4e7d3f94fff) previously allocated by thread T11 here: #0 0x73ea2ed73108 in operator new(unsigned long) (/nix/store/03bq5hc45d5wkw8pajmz4vgd5s0ivyq8-clang-wrapper-18.1.8/resource-root/lib/linux/libclang_rt.asan-x86_64.so+0x173108) #1 0x5877382db362 in std::__new_allocator<std::_Rb_tree_node<nix::StorePath>>::allocate(unsigned long, void const*) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/new_allocator.h:151:27 #2 0x5877382db362 in std::allocator<std::_Rb_tree_node<nix::StorePath>>::allocate(unsigned long) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/allocator.h:198:32 #3 0x5877382db362 in std::allocator_traits<std::allocator<std::_Rb_tree_node<nix::StorePath>>>::allocate(std::allocator<std::_Rb_tree_node<nix::StorePath>>&, unsigned long) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/alloc_traits.h:482:20 #4 0x5877382db362 in std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_M_get_node() /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:563:16 #5 0x5877382db362 in std::_Rb_tree_node<nix::StorePath>* 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&>(nix::StorePath const&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:613:23 #6 0x5877382db362 in std::_Rb_tree_node<nix::StorePath>* 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&>(nix::StorePath const&) const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:531:18 #7 0x5877382db362 in std::_Rb_tree_iterator<nix::StorePath> 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>(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, nix::StorePath const&, std::_Rb_tree<nix::StorePath, nix::StorePath, std::_Identity<nix::StorePath>, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::_Alloc_node&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:1831:19 #8 0x5877382db362 in std::pair<std::_Rb_tree_iterator<nix::StorePath>, bool> 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&>(nix::StorePath const&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_tree.h:2176:16 #9 0x73ea2df68684 in std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>>::insert(nix::StorePath const&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/stl_set.h:514:9 #10 0x73ea2df68684 in void nix::processGraph<nix::StorePath>(nix::ThreadPool&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, std::function<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> (nix::StorePath const&)>, std::function<void (nix::StorePath const&)>)::'lambda'(nix::StorePath const&)::operator()(nix::StorePath const&) const /home/myuser/lix/build/lix/libutil/thread-pool.hh:122:43 #11 0x73ea2e6b8aff in std::function<void ()>::operator()() const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/std_function.h:591:9 #12 0x73ea2e6b8aff in nix::ThreadPool::doWork(bool) /home/myuser/lix/build/lix/libutil/thread-pool.cc:161:13 #13 0x73ea2c8e86d2 in execute_native_thread_routine (/nix/store/ybjcla5bhj8g1y84998pn4a2drfxybkv-gcc-13.3.0-lib/lib/libstdc++.so.6+0xe86d2) Thread T14 created by T0 here: #0 0x73ea2ed59ecd in pthread_create (/nix/store/03bq5hc45d5wkw8pajmz4vgd5s0ivyq8-clang-wrapper-18.1.8/resource-root/lib/linux/libclang_rt.asan-x86_64.so+0x159ecd) #1 0x73ea2c8e87a8 in std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>, void (*)()) (/nix/store/ybjcla5bhj8g1y84998pn4a2drfxybkv-gcc-13.3.0-lib/lib/libstdc++.so.6+0xe87a8) #2 0x73ea2e6b8038 in nix::ThreadPool::enqueue(std::function<void ()> const&) /home/myuser/lix/build/lix/libutil/thread-pool.cc:51:24 #3 0x73ea2df5f5be in void nix::processGraph<nix::StorePath>(nix::ThreadPool&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, std::function<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> (nix::StorePath const&)>, std::function<void (nix::StorePath const&)>) /home/myuser/lix/build/lix/libutil/thread-pool.hh:153:14 #4 0x73ea2df3249c in nix::Store::addMultipleToStore(std::vector<std::pair<nix::ValidPathInfo, std::unique_ptr<nix::Source, std::default_delete<nix::Source>>>, std::allocator<std::pair<nix::ValidPathInfo, std::unique_ptr<nix::Source, std::default_delete<nix::Source>>>>>&, nix::Activity&, nix::RepairFlag, nix::CheckSigsFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:311:5 #5 0x73ea2df4d2dd in nix::copyPaths(nix::Store&, nix::Store&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, nix::RepairFlag, nix::CheckSigsFlag, nix::SubstituteFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:1259:14 #6 0x73ea2df4ae5d in nix::copyPaths(nix::Store&, nix::Store&, std::set<nix::RealisedPath, std::less<nix::RealisedPath>, std::allocator<nix::RealisedPath>> const&, nix::RepairFlag, nix::CheckSigsFlag, nix::SubstituteFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:1138:21 #7 0x5877381b1188 in CmdCopy::run(nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath>>&&) /home/myuser/lix/build/lix/nix/copy.cc:57:9 #8 0x73ea2e938ee1 in nix::BuiltPathsCommand::run(nix::ref<nix::Store>, std::vector<nix::ref<nix::Installable>, std::allocator<nix::ref<nix::Installable>>>&&) /home/myuser/lix/build/lix/libcmd/command.cc:180:5 #9 0x73ea2e9c2dae in nix::InstallablesCommand::run(nix::ref<nix::Store>, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&&) /home/myuser/lix/build/lix/libcmd/installables.cc:846:5 #10 0x73ea2e9c18e5 in nix::RawInstallablesCommand::run(nix::ref<nix::Store>) /home/myuser/lix/build/lix/libcmd/installables.cc:831:5 #11 0x73ea2e9320bb in nix::StoreCommand::run() /home/myuser/lix/build/lix/libcmd/command.cc:49:5 #12 0x58773831e1fe in nix::mainWrapped(int, char**) /home/myuser/lix/build/lix/nix/main.cc:529:10 #13 0x73ea2d9d1f54 in std::function<void ()>::operator()() const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/std_function.h:591:9 #14 0x73ea2d9d1f54 in nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::function<void ()>) /home/myuser/lix/build/lix/libmain/shared.cc:311:9 #15 0x587738322687 in main /home/myuser/lix/build/lix/nix/main.cc:545:12 #16 0x73ea2c63127d in __libc_start_call_main (/nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6+0x2a27d) (BuildId: 5c3f64ce109fb7a0be214b5e31d2a4e7d3f94fff) Thread T11 created by T0 here: #0 0x73ea2ed59ecd in pthread_create (/nix/store/03bq5hc45d5wkw8pajmz4vgd5s0ivyq8-clang-wrapper-18.1.8/resource-root/lib/linux/libclang_rt.asan-x86_64.so+0x159ecd) #1 0x73ea2c8e87a8 in std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>, void (*)()) (/nix/store/ybjcla5bhj8g1y84998pn4a2drfxybkv-gcc-13.3.0-lib/lib/libstdc++.so.6+0xe87a8) #2 0x73ea2e6ba01a in std::thread& std::vector<std::thread, std::allocator<std::thread>>::emplace_back<void (nix::ThreadPool::*)(bool), nix::ThreadPool*, bool>(void (nix::ThreadPool::*&&)(bool), nix::ThreadPool*&&, bool&&) /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/vector.tcc:123:4 #3 0x73ea2e6b8038 in nix::ThreadPool::enqueue(std::function<void ()> const&) /home/myuser/lix/build/lix/libutil/thread-pool.cc:51:24 #4 0x73ea2df5f5be in void nix::processGraph<nix::StorePath>(nix::ThreadPool&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, std::function<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> (nix::StorePath const&)>, std::function<void (nix::StorePath const&)>) /home/myuser/lix/build/lix/libutil/thread-pool.hh:153:14 #5 0x73ea2df3249c in nix::Store::addMultipleToStore(std::vector<std::pair<nix::ValidPathInfo, std::unique_ptr<nix::Source, std::default_delete<nix::Source>>>, std::allocator<std::pair<nix::ValidPathInfo, std::unique_ptr<nix::Source, std::default_delete<nix::Source>>>>>&, nix::Activity&, nix::RepairFlag, nix::CheckSigsFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:311:5 #6 0x73ea2df4d2dd in nix::copyPaths(nix::Store&, nix::Store&, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath>> const&, nix::RepairFlag, nix::CheckSigsFlag, nix::SubstituteFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:1259:14 #7 0x73ea2df4ae5d in nix::copyPaths(nix::Store&, nix::Store&, std::set<nix::RealisedPath, std::less<nix::RealisedPath>, std::allocator<nix::RealisedPath>> const&, nix::RepairFlag, nix::CheckSigsFlag, nix::SubstituteFlag) /home/myuser/lix/build/lix/libstore/store-api.cc:1138:21 #8 0x5877381b1188 in CmdCopy::run(nix::ref<nix::Store>, std::vector<nix::BuiltPath, std::allocator<nix::BuiltPath>>&&) /home/myuser/lix/build/lix/nix/copy.cc:57:9 #9 0x73ea2e938ee1 in nix::BuiltPathsCommand::run(nix::ref<nix::Store>, std::vector<nix::ref<nix::Installable>, std::allocator<nix::ref<nix::Installable>>>&&) /home/myuser/lix/build/lix/libcmd/command.cc:180:5 #10 0x73ea2e9c2dae in nix::InstallablesCommand::run(nix::ref<nix::Store>, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&&) /home/myuser/lix/build/lix/libcmd/installables.cc:846:5 #11 0x73ea2e9c18e5 in nix::RawInstallablesCommand::run(nix::ref<nix::Store>) /home/myuser/lix/build/lix/libcmd/installables.cc:831:5 #12 0x73ea2e9320bb in nix::StoreCommand::run() /home/myuser/lix/build/lix/libcmd/command.cc:49:5 #13 0x58773831e1fe in nix::mainWrapped(int, char**) /home/myuser/lix/build/lix/nix/main.cc:529:10 #14 0x73ea2d9d1f54 in std::function<void ()>::operator()() const /nix/store/4krab2h0hd4wvxxmscxrw21pl77j4i7j-gcc-13.3.0/include/c++/13.3.0/bits/std_function.h:591:9 #15 0x73ea2d9d1f54 in nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::function<void ()>) /home/myuser/lix/build/lix/libmain/shared.cc:311:9 #16 0x587738322687 in main /home/myuser/lix/build/lix/nix/main.cc:545:12 #17 0x73ea2c63127d in __libc_start_call_main (/nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6+0x2a27d) (BuildId: 5c3f64ce109fb7a0be214b5e31d2a4e7d3f94fff) SUMMARY: AddressSanitizer: heap-use-after-free /home/myuser/lix/build/lix/libstore/path.hh:46:25 in nix::StorePath::operator<(nix::StorePath const&) const Shadow bytes around the buggy address: 0x50600b32ae00: fd fd fd fd fa fa fa fa fd fd fd fd fd fd fd fd 0x50600b32ae80: fa fa fa fa fd fd fd fd fd fd fd fd fa fa fa fa 0x50600b32af00: fd fd fd fd fd fd fd fd fa fa fa fa fd fd fd fd 0x50600b32af80: fd fd fd fd fa fa fa fa fd fd fd fd fd fd fd fd 0x50600b32b000: fa fa fa fa fd fd fd fd fd fd fd fd fa fa fa fa =>0x50600b32b080: fd fd fd fd fd[fd]fd fd fa fa fa fa fd fd fd fd 0x50600b32b100: fd fd fd fd fa fa fa fa fd fd fd fd fd fd fd fd 0x50600b32b180: fa fa fa fa fd fd fd fd fd fd fd fa fa fa fa fa 0x50600b32b200: fd fd fd fd fd fd fd fd fa fa fa fa fd fd fd fd 0x50600b32b280: fd fd fd fd fa fa fa fa 00 00 00 00 00 00 00 00 0x50600b32b300: fa fa fa fa 00 00 00 00 00 00 00 00 fa fa fa fa Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==3187895==ABORTING ``` ## Steps To Reproduce 1. find some flake-based system config 2. run nix copy to some random directory, or ssh, or anything as above. 3. observe crashes ## Expected behavior Shouldn't crash. ## `nix --version` output reproduced on 3413ab56292f12ac03ee49270bcaf16038020cb3 (today's main) and nixos 24.11's lix, 2.91.1 ## Additional context None at this time.
martinetd added the
bug
label 2025-01-08 08:06:27 +00:00
Author

So the problem seems to be with the addMultipleToStore thread pool in lix/libstore/store-api.cc ..

Since it's a data race I tried building with TSan as well, attached the log with many many warnings for anyone who'd like to try to decipher this; I found it slightly easier to read but perhaps it's just that I had looked at the code in between.

The race would be between the Graph destructor (from leaving processGraph?) and graph->rrefs[ref].insert(node); in one of the threads.
The later is done under graph_.lock(), but the destructors obviously don't take it, but it shouldn't matter anymore because my understanding from the thread pool after a quick read is that it should no longer be running after pool.process()...

OTOH TSan is clear that the main thread is running the destructor at this point, so what we need to look for is why a thread would still be running after pool.process() - that would obviously cause problems.
Any idea?

(FWIW this also seems to affect nix, so that is not a new lix bug)

So the problem seems to be with the addMultipleToStore thread pool in lix/libstore/store-api.cc .. Since it's a data race I tried building with TSan as well, attached the log with many many warnings for anyone who'd like to try to decipher this; I found it slightly easier to read but perhaps it's just that I had looked at the code in between. The race would be between the Graph destructor (from leaving processGraph?) and `graph->rrefs[ref].insert(node);` in one of the threads. The later is done under graph_.lock(), but the destructors obviously don't take it, but it shouldn't matter anymore because my understanding from the thread pool after a quick read is that it should no longer be running after pool.process()... OTOH TSan is clear that the main thread is running the destructor at this point, so what we need to look for is why a thread would still be running after `pool.process()` - that would obviously cause problems. Any idea? (FWIW this also seems to affect nix, so that is not a new lix bug)
7.5 MiB
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#618
No description provided.