nix icon indicating copy to clipboard operation
nix copied to clipboard

Exception: std::__1::system_error: mutex lock failed: Invalid argument

Open DamienCassou opened this issue 2 months ago • 6 comments

Describe the bug

error:
       … while evaluating the attribute 'optionalValue.value'
         at /nix/store/ybmnblw90230yl4p0l18ghwx9ry597bz-source/lib/modules.nix:1227:5:
         1226|
         1227|     optionalValue = if isDefined then { value = mergedValue; } else { };
             |     ^
         1228|   };

       … while evaluating a branch condition
         at /nix/store/ybmnblw90230yl4p0l18ghwx9ry597bz-source/lib/modules.nix:1227:21:
         1226|
         1227|     optionalValue = if isDefined then { value = mergedValue; } else { };
             |                     ^
         1228|   };

       … while evaluating definitions from `/nix/store/dlg5pdiaijls9qmyjrsrcplqjvsisxpn-source/modules/system':

       … while evaluating the option `home-manager.users.cassou.launchd.agents.syncthing-init.enable':

       … while evaluating definitions from `/nix/store/mbhbwy5ycdh1cb8w0v8bc7dslbp8lxbw-source/modules/services/syncthing.nix':

       … while evaluating the option `home-manager.users.cassou.services.syncthing.settings.folders':

       … while evaluating definitions from `/nix/store/hv5hzxsv9fkm9vb8zag9jcrf71rslc61-source/secrets/syncthing/macbook':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: expected a set but found a path: /nix/store/hv5hzxsv9fkm9vb8zag9jcrf71rslc61-source/secrets/syncthing/folders
Nix crashed. This is a bug. Please report this at https://github.com/NixOS/nix/issues with the following information included:

Exception: std::__1::system_error: mutex lock failed: Invalid argument
Stack trace:
 0# nix::(anonymous namespace)::onTerminate() in /nix/store/8v5k2101fr0qwabbqb8l3pqd807lk6mk-nix-2.28.5/bin/nix
 1# std::__terminate(void (*)()) in /nix/store/8qhdaryhrcvz2mfgvhci2j63qa22bjsl-libcxx-19.1.7/lib/libc++abi.1.0.dylib
 2# __cxa_get_exception_ptr in /nix/store/8qhdaryhrcvz2mfgvhci2j63qa22bjsl-libcxx-19.1.7/lib/libc++abi.1.0.dylib
 3# __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) in /nix/store/8qhdaryhrcvz2mfgvhci2j63qa22bjsl-libcxx-19.1.7/lib/libc++abi.1.0.dylib
 4# std::__1::__throw_system_error[abi:ne190107](std::__1::error_code, char const*) in /nix/store/8qhdaryhrcvz2mfgvhci2j63qa22bjsl-libcxx-19.1.7/lib/libc++.1.0.dylib
 5# std::__1::__throw_system_error[abi:ne190107](std::__1::error_code, char const*) in /nix/store/8qhdaryhrcvz2mfgvhci2j63qa22bjsl-libcxx-19.1.7/lib/libc++.1.0.dylib
 6# std::__1::mutex::try_lock() in /nix/store/8qhdaryhrcvz2mfgvhci2j63qa22bjsl-libcxx-19.1.7/lib/libc++.1.0.dylib
 7# nix::updateWindowSize() in /nix/store/8v5k2101fr0qwabbqb8l3pqd807lk6mk-nix-2.28.5/lib/libnixutil.dylib
 8# nix::signalHandlerThread(unsigned int) in /nix/store/8v5k2101fr0qwabbqb8l3pqd807lk6mk-nix-2.28.5/lib/libnixutil.dylib
 9# void* std::__1::__thread_proxy[abi:fe190107]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (*)(unsigned int), unsigned int>>(void*) in /nix/store/8v5k2101fr0qwabbqb8l3pqd807lk6mk-nix-2.28.5/lib/libnixutil.dylib
10# _pthread_start in /usr/lib/system/libsystem_pthread.dylib

Steps To Reproduce

I have code like this:

{
  inherit (../folders) foo;
}

with ../folders/default.nix looking like this:

{
  foo = { ... };
}

Expected behavior

I would have expected an error message "expected a set but found a path" but not a trace.

Metadata

nix-env (Nix) 2.28.5

Additional context

Checklist


Add :+1: to issues you find important.

DamienCassou avatar Oct 19 '25 16:10 DamienCassou

Same on macOS 26.0.1.

But in my case, running it the second time didn't trigger this.

Exception: std::__1::system_error: mutex lock failed: Invalid argument
Stack trace:
 0# nix::(anonymous namespace)::onTerminate() in /nix/store/p556nqjd3a2l0hdph9vixbcmgag4n9ai-nix-3.8.2/bin/nix
 1# std::__terminate(void (*)()) in /nix/store/qh3kz2ywxgq1fl4ngkbav298nmgybnaq-libcxx-19.1.7/lib/libc++abi.1.0.dylib
 2# __cxa_get_exception_ptr in /nix/store/qh3kz2ywxgq1fl4ngkbav298nmgybnaq-libcxx-19.1.7/lib/libc++abi.1.0.dylib
 3# __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) in /nix/store/qh3kz2ywxgq1fl4ngkbav298nmgybnaq-libcxx-19.1.7/lib/libc++abi.1.0.dylib
 4# std::__1::__throw_system_error[abi:ne190107](std::__1::error_code, char const*) in /nix/store/qh3kz2ywxgq1fl4ngkbav298nmgybnaq-libcxx-19.1.7/lib/libc++.1.0.dylib
 5# std::__1::__throw_system_error[abi:ne190107](std::__1::error_code, char const*) in /nix/store/qh3kz2ywxgq1fl4ngkbav298nmgybnaq-libcxx-19.1.7/lib/libc++.1.0.dylib
 6# std::__1::mutex::try_lock() in /nix/store/qh3kz2ywxgq1fl4ngkbav298nmgybnaq-libcxx-19.1.7/lib/libc++.1.0.dylib
 7# nix::getWindowSize() in /nix/store/l2zszm08w155c8z4f6pcisvbpqcd6yvp-determinate-nix-util-3.8.2/lib/libnixutil.dylib
 8# nix::ProgressBar::draw(nix::ProgressBar::State&) in /nix/store/j8if2r99f136gr4iw2ryykzskrr260sz-determinate-nix-main-3.8.2/lib/libnixmain.dylib
 9# nix::ProgressBar::ProgressBar(bool)::'lambda'()::operator()() const in /nix/store/j8if2r99f136gr4iw2ryykzskrr260sz-determinate-nix-main-3.8.2/lib/libnixmain.dylib
10# void* std::__1::__thread_proxy[abi:fe190107]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, nix::ProgressBar::ProgressBar(bool)::'lambda'()>>(void*) in /nix/store/j8if2r99f136gr4iw2ryykzskrr260sz-determinate-nix-main-3.8.2/lib/libnixmain.dylib
11# _pthread_start in /usr/lib/system/libsystem_pthread.dylib

/Users/ken/.nix-profile/bin/home-manager: line 552: 73934 Abort trap: 6              nix build "${extraArgs[@]}" "${PASSTHROUGH_OPTS[@]}"

EDIT: Not so same, our stack trace seems different

SuperKenVery avatar Oct 24 '25 07:10 SuperKenVery

@DamienCassou Can you reproduce that with a more recent Nix version?

I couldn't reproduce it (either with 2.28.5 or master on macOS). I tried:

> cat foo.nix                                                                                                                                                                                                  ~/crash/x
{
  inherit (../folders) foo;
}

> nix eval --file ./foo.nix                                                                                                                                                                                    ~/crash/x
{ foo = «error: expected a set but found a path: /Users/ephemeraladmin/crash/folders»; }

@SuperKenVery Do you have a reproducer for that?

edolstra avatar Nov 05 '25 21:11 edolstra

No, even running the same code the second time didn't trigger it. It's probably safe to ignore my report 😆

SuperKenVery avatar Nov 06 '25 03:11 SuperKenVery

I can't reproduce anymore. Feel free to close the issue.

DamienCassou avatar Nov 06 '25 09:11 DamienCassou

I just produced this in a CI run:

NixOS-packages.json-ga.json> Done NixOS-packages.json-ga.json
building '/nix/store/ldj68ywh0kx6kcw5r5ffwgn8m7lzv4nx-NixOS-packages.json-gd.json.drv'...
NixOS-packages.json-gd.json> Building NixOS-packages.json-gd.json
NixOS-packages.json-gc.json> Nix crashed. This is a bug. Please report this at https://github.com/NixOS/nix/issues with the following information included:
NixOS-packages.json-gc.json> 
NixOS-packages.json-gc.json> Exception: std::__1::system_error: mutex lock failed: Invalid argument
NixOS-packages.json-gc.json> Stack trace:
NixOS-packages.json-gc.json>  0# nix::(anonymous namespace)::onTerminate() in /nix/store/r8yv70fsy7rnh9cfc7pp3066l10jdn3q-nix-2.32.4/bin/nix
NixOS-packages.json-gc.json>  1# std::__terminate(void (*)()) in /usr/lib/libc++abi.dylib
NixOS-packages.json-gc.json>  2# __cxa_get_exception_ptr in /usr/lib/libc++abi.dylib
NixOS-packages.json-gc.json>  3# __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) in /usr/lib/libc++abi.dylib
NixOS-packages.json-gc.json>  4# std::__1::__throw_system_error[abi:ne190102](std::__1::error_code, char const*) in /usr/lib/libc++.1.dylib
NixOS-packages.json-gc.json>  5# std::__1::__throw_system_error[abi:ne190102](std::__1::error_code, char const*) in /usr/lib/libc++.1.dylib
NixOS-packages.json-gc.json>  6# std::__1::mutex::try_lock() in /usr/lib/libc++.1.dylib
NixOS-packages.json-gc.json>  7# nix::getWindowSize() in /nix/store/3h6f9yv76g2fc4mvl3qjkf432s4xc5b9-nix-util-2.32.4/lib/libnixutil.2.32.4.dylib
NixOS-packages.json-gc.json>  8# nix::ProgressBar::draw(nix::ProgressBar::State&) in /nix/store/s7vzwallhi807yva6491xzqq27vlwzch-nix-main-2.32.4/lib/libnixmain.2.32.4.dylib
NixOS-packages.json-gc.json>  9# nix::ProgressBar::ProgressBar(bool)::'lambda'()::operator()() const in /nix/store/s7vzwallhi807yva6491xzqq27vlwzch-nix-main-2.32.4/lib/libnixmain.2.32.4.dylib
NixOS-packages.json-gc.json> 10# void* std::__1::__thread_proxy[abi:se190102]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, nix::ProgressBar::ProgressBar(bool)::'lambda'()>>(void*) in /nix/store/s7vzwallhi807yva6491xzqq27vlwzch-nix-main-2.32.4/lib/libnixmain.2.32.4.dylib
NixOS-packages.json-gc.json> 11# _pthread_start in /usr/lib/system/libsystem_pthread.dylib
NixOS-packages.json-gc.json> 
NixOS-packages.json-gc.json> /nix/var/nix/builds/nix-5020-825674937/.attr-0l2nkwhif96f51f4amnlf414lhl4rv9vh8iffyp431v6s28gsr90: line 16: 23509 Abort trap: 6              NIX_STATE_DIR=$TMPDIR NIX_PATH= nix --extra-experimental-features nix-command eval --impure --json --offline --quiet --read-only --show-trace --expr '(import ./build-packages.nix { inherit (import /nix/store/k4hmx6m5ck6fhx16hxf92mgqgmws58vq-source {}) lib; }).buildPackages' > $out

The installed used https://releases.nixos.org/nix/nix-2.32.4/nix-2.32.4-aarch64-darwin.tar.xz to install nix.

https://github.com/NuschtOS/search/actions/runs/19916942764/job/57097802479?pr=280

SuperSandro2000 avatar Dec 04 '25 16:12 SuperSandro2000

@SuperSandro2000 also told me that this is related to tight memory pressure in CI.

Mic92 avatar Dec 04 '25 16:12 Mic92