nix icon indicating copy to clipboard operation
nix copied to clipboard

random nix-daemon crash when using nh os switch

Open N4CH723HR3R opened this issue 11 months ago • 3 comments

Describe the bug

i was updating my system in the background when this happened

Steps To Reproduce

this randomly happened with nh --elevation-program run0 os switch .

Expected behavior

no crash

Metadata

nix-env (Nix) 2.31.2

Additional context

Dez 10 00:58:23 nix-daemon[229320]: Nix crashed. This is a bug. Please report this at https://github.com/NixOS/nix/issues with the following information included: Dez 10 00:58:23 nix-daemon[229320]: Exception: nix::Interrupted: error: interrupted by the user Dez 10 00:58:23 nix-daemon[229320]: Stack trace: Dez 10 00:58:23 nix-daemon[229320]: 0# 0x000055863B652551 in nix-daemon Dez 10 00:58:23 nix-daemon[229320]: 1# 0x00007F1A8BCBF1AA in /nix/store/xm08aqdd7pxcdhm0ak6aqb1v7hw5q6ri-gcc-14.3.0-lib/lib/libstdc++.so.6 Dez 10 00:58:23 nix-daemon[229320]: 2# std::unexpected() in /nix/store/xm08aqdd7pxcdhm0ak6aqb1v7hw5q6ri-gcc-14.3.0-lib/lib/libstdc++.so.6 Dez 10 00:58:23 nix-daemon[229320]: 3# 0x00007F1A8BCAD800 in /nix/store/xm08aqdd7pxcdhm0ak6aqb1v7hw5q6ri-gcc-14.3.0-lib/lib/libstdc++.so.6 Dez 10 00:58:23 nix-daemon[229320]: 4# 0x00007F1A8C6A81DF in /nix/store/3cv2fqgkp4jd03rc5nqlsg9zc7fvh5bs-nix-store-2.31.2/lib/libnixstore.so Dez 10 00:58:23 nix-daemon[229320]: 5# 0x00007F1A8C76B422 in /nix/store/3cv2fqgkp4jd03rc5nqlsg9zc7fvh5bs-nix-store-2.31.2/lib/libnixstore.so Dez 10 00:58:23 nix-daemon[229320]: 6# nix::ignoreExceptionExceptInterrupt(nix::Verbosity) in /nix/store/c613jxwz29sghszq5ic3kybw312dc59x-nix-util-2.31.2/lib/libnixutil.so Dez 10 00:58:23 nix-daemon[229320]: 7# 0x00007F1A8CABE489 in /nix/store/c613jxwz29sghszq5ic3kybw312dc59x-nix-util-2.31.2/lib/libnixutil.so Dez 10 00:58:23 nix-daemon[229320]: 8# 0x00007F1A8BCED064 in /nix/store/xm08aqdd7pxcdhm0ak6aqb1v7hw5q6ri-gcc-14.3.0-lib/lib/libstdc++.so.6 Dez 10 00:58:23 nix-daemon[229320]: 9# 0x00007F1A8B89A97A in /nix/store/xx7cm72qy2c0643cm1ipngd87aqwkcdp-glibc-2.40-66/lib/libc.so.6 Dez 10 00:58:23 nix-daemon[229320]: 10# 0x00007F1A8B922D2C in /nix/store/xx7cm72qy2c0643cm1ipngd87aqwkcdp-glibc-2.40-66/lib/libc.so.6 Dez 10 00:58:23 nix-daemon[229320]: Nix crashed. This is a bug. Please report this at https://github.com/NixOS/nix/issues with the following information included: Dez 10 00:58:23 nix-daemon[229320]: Exception: nix::Interrupted: error: interrupted by the user Dez 10 00:58:23 nix-daemon[229320]: Stack trace: Dez 10 00:58:23 nix-daemon[229320]: 0# 0x000055863B652551 in nix-daemon 1# 0x00007F1A8BCBF1AA in /nix/store/xm08aqdd7pxcdhm0ak6aqb1v7hw5q6ri-gcc-14.3.0-lib/lib/libstdc++.so.6 2# std::unexpected() in /nix/store/xm08aqdd7pxcdhm0ak6aqb1v7hw5q6ri-gcc-14.3.0-lib/lib/libstdc++.so.6 3# 0x00007F1A8BCAD800 in /nix/store/xm08aqdd7pxcdhm0ak6aqb1v7hw5q6ri-gcc-14.3.0-lib/lib/libstdc++.so.6 4# 0x00007F1A8C6A81DF in /nix/store/3cv2fqgkp4jd03rc5nqlsg9zc7fvh5bs-nix-store-2.31.2/lib/libnixstore.so 5# 0x00007F1A8C76B422 in /nix/store/3cv2fqgkp4jd03rc5nqlsg9zc7fvh5bs-nix-store-2.31.2/lib/libnixstore.so 6# nix::ignoreExceptionExceptInterrupt(nix::Verbosity) in /nix/store/c613jxwz29sghszq5ic3kybw312dc59x-nix-util-2.31.2/lib/libnixutil.so 7# 0x00007F1A8CABE489 in /nix/store/c613jxwz29sghszq5ic3kybw312dc59x-nix-util-2.31.2/lib/libnixutil.so 8# 0x00007F1A8BCED064 in /nix/store/xm08aqdd7pxcdhm0ak6aqb1v7hw5q6ri-gcc-14.3.0-lib/lib/libstdc++.so.6 9# 0x00007F1A8B89A97A in /nix/store/xx7cm72qy2c0643cm1ipngd87aqwkcdp-glibc-2.40-66/lib/libc.so.6 10# 0x00007F1A8B922D2C in /nix/store/xx7cm72qy2c0643cm1ipngd87aqwkcdp-glibc-2.40-66/lib/libc.so.6

Checklist

  • [x] checked [latest Nix manual] ([source])
  • [x] checked [open bug issues and pull requests] for possible duplicates

N4CH723HR3R avatar Dec 10 '25 00:12 N4CH723HR3R

I don't think this has anything to do with nh and is a general bug.

SuperSandro2000 avatar Jan 14 '26 14:01 SuperSandro2000

I don't think this has anything to do with nh and is a general bug.

yeah, i think so too but i wanted to provide additional context

N4CH723HR3R avatar Jan 15 '26 04:01 N4CH723HR3R

same issue here on a raspi (dont know if this is relevant), based on that i have not enough knowledge about nixos i can only provide a ai generated issue information, i hope that is okay and is helpful:

if it brings anything here a few systems informations:

nix-shell -p nix-info --run "nix-info -m" 
this path will be fetched (16.4 KiB download, 60.0 KiB unpacked):
  /nix/store/x2nn0gxp53a95nl72xysa73vn3pjk8xm-stdenv-linux
copying path '/nix/store/x2nn0gxp53a95nl72xysa73vn3pjk8xm-stdenv-linux' from 'https://cache.nixos.org'...
 - system: `"aarch64-linux"`
 - host os: `Linux 6.18.34, NixOS, 26.11 (Zokor), 26.11.20260715.753cc8a`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.34.8`
 - channels(root): `"nixos"`
 - nixpkgs: `/nix/store/7hlsbdxjq2mgczhlipabzn52sarzx0yd-source`

Crash Analysis & Root Cause for TunnelLogger::enqueueMsg / ThreadPool::doWork SIGABRT

Happened on Nix 2.34.8 when parallel worker threads in ThreadPool fail (specifically when a configured binary cache or remote builder is unreachable).

Stack Trace

  #0  __pthread_kill_implementation (libc.so.6)
  #1  raise
  #2  abort
  #3  nix::(anonymous namespace)::onTerminate()
  #4  __cxxabiv1::__terminate(void (*)())
  #5  std::terminate()
  #6  __cxa_rethrow
  #7  nix::daemon::TunnelLogger::enqueueMsg(std::string const&)
  #8  nix::daemon::TunnelLogger::log(nix::Verbosity, std::string_view)
  #9  nix::ignoreExceptionExceptInterrupt(nix::Verbosity)
  #10 nix::ThreadPool::doWork(bool)
  #11 execute_native_thread_routine (libstdc++.so.6)
  #12 start_thread (libc.so.6)

Explanation

  1. When multiple workers in ThreadPool fail simultaneously, secondary workers execute:

    /* Print the exception, since we can't propagate it. */
    try {
        std::rethrow_exception(exc);
    } catch (std::exception & e) {
        ignoreExceptionExceptInterrupt();
    }
    
    
  2. ignoreExceptionExceptInterrupt() invokes printMsg(), which logs through TunnelLogger::log -> TunnelLogger::enqueueMsg.

  3. If writing to the client socket fails or throws inside TunnelLogger::enqueueMsg (or if ignoreExceptionExceptInterrupt() re-throws Interrupted), the exception escapes ThreadPool::doWork.

  4. Because ThreadPool::doWork runs directly inside std::thread, escaping exceptions cause std::terminate() to be invoked, killing nix-daemon with SIGABRT.

Xyz00777 avatar Aug 31 '26 16:08 Xyz00777