Exception: std::regex_error: Mismatched '(' and ')' in regular expression #813

Closed
opened 2025-04-28 19:35:33 +00:00 by puercopop · 4 comments

Describe the bug

Passing *emacs as the argument to nix-env --query crashes lix

Steps To Reproduce

  1. Evaluate $ nix-env --query '*emacs'

Note the quotes, otherwise a shell expansion might interfere if the current working directory has a file that matches that expansion.

Expected behavior

For lix not to crash. ej. print out

error: selector '*emacs' matches no derivations

nix --version output

$ nix --version
nix (Lix, like Nix) 2.93.0-dev
System type: x86_64-linux
Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /home/puercopop/.config/nix/nix.conf:/nix/store/4s5qgbm8x6m69nrv9iml2b5lw5l8idyv-plasma-workspace-6.3.4/etc/xdg/nix/nix.conf:/nix/store/2nk3cjv5c75qlicn3j12zpb21d9cm9jv-kglobalacceld-6.3.4/etc/xdg/nix/nix.conf:/nix/store/6gpcrbcdsqx19nyn0swksyqf96297kzd-baloo-6.13.0/etc/xdg/nix/nix.conf:/home/puercopop/.config/kdedefaults/nix/nix.conf:/nix/store/4s5qgbm8x6m69nrv9iml2b5lw5l8idyv-plasma-workspace-6.3.4/etc/xdg/nix/nix.conf:/nix/store/2nk3cjv5c75qlicn3j12zpb21d9cm9jv-kglobalacceld-6.3.4/etc/xdg/nix/nix.conf:/nix/store/6gpcrbcdsqx19nyn0swksyqf96297kzd-baloo-6.13.0/etc/xdg/nix/nix.conf:/home/puercopop/.config/kdedefaults/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/puercopop/.local/share/flatpak/exports/etc/xdg/nix/nix.conf:/var/lib/flatpak/exports/etc/xdg/nix/nix.conf:/home/puercopop/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/puercopop/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/puercopop/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/rzc0zz8y2gwp0nlgi264z0h8p4wll8wj-lix-2.93.0-dev/share

Additional context

Stack trace
Exception: std::regex_error: Mismatched '(' and ')' in regular expression
Stack trace:
 0# nix::getStackTrace[abi:cxx11]() in /nix/store/rzc0zz8y2gwp0nlgi264z0h8p4wll8wj-lix-2.93.0-dev/lib/liblixutil.so
 1# 0x00007EFD30417B10 in /nix/store/rzc0zz8y2gwp0nlgi264z0h8p4wll8wj-lix-2.93.0-dev/lib/liblixmain.so
 2# 0x00007EFD2ECBF1CA in /nix/store/7n3q3rgy5382di7ccrh3r6gk2xp51dh7-gcc-14.2.1.20250322-lib/lib/libstdc++.so.6
 3# std::unexpected() in /nix/store/7n3q3rgy5382di7ccrh3r6gk2xp51dh7-gcc-14.2.1.20250322-lib/lib/libstdc++.so.6
 4# 0x00007EFD2ECBF447 in /nix/store/7n3q3rgy5382di7ccrh3r6gk2xp51dh7-gcc-14.2.1.20250322-lib/lib/libstdc++.so.6
 5# std::__throw_regex_error(std::regex_constants::error_type) in /nix/store/7n3q3rgy5382di7ccrh3r6gk2xp51dh7-gcc-14.2.1.20250322-lib/lib/libstdc++.so.6
 6# std::__detail::_Compiler<std::__cxx11::regex_traits<char> >::_Compiler(char const*, char const*, std::locale const&, std::regex_constants::syntax_option_type) in /nix/store/rzc0zz8y2gwp0nlgi264z0h8p4wll8wj-lix-2.93.0-dev/lib/liblixutil.so
 7# std::__cxx11::basic_regex<char, std::__cxx11::regex_traits<char> >::_M_compile(char const*, char const*, std::regex_constants::syntax_option_type) in /nix/store/rzc0zz8y2gwp0nlgi264z0h8p4wll8wj-lix-2.93.0-dev/lib/liblixutil.so
 8# nix::DrvName::matches(nix::DrvName const&) in /nix/store/rzc0zz8y2gwp0nlgi264z0h8p4wll8wj-lix-2.93.0-dev/lib/liblixstore.so
 9# 0x000055E2DADC0045 in nix-env
10# 0x000055E2DADB482F in nix-env
11# 0x000055E2DADAD936 in nix-env
12# 0x000055E2DAC6656B in nix-env
13# 0x000055E2DAD030EB in nix-env
14# 0x000055E2DAD076DD in nix-env
15# nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<void ()>) in /nix/store/rzc0zz8y2gwp0nlgi264z0h8p4wll8wj-lix-2.93.0-dev/lib/liblixmain.so
16# 0x000055E2DAD06F9B in nix-env
17# 0x00007EFD2E82A47E in /nix/store/vbrdc5wgzn0w1zdp10xd2favkjn5fk7y-glibc-2.40-66/lib/libc.so.6
18# __libc_start_main in /nix/store/vbrdc5wgzn0w1zdp10xd2favkjn5fk7y-glibc-2.40-66/lib/libc.so.6
19# 0x000055E2DAC2F6C5 in nix-env

Aborted (core dumped)
## Describe the bug Passing `*emacs` as the argument to `nix-env --query` crashes lix ## Steps To Reproduce 1. Evaluate `$ nix-env --query '*emacs'` Note the quotes, otherwise a shell expansion might interfere if the current working directory has a file that matches that expansion. ## Expected behavior For lix not to crash. ej. print out ``` error: selector '*emacs' matches no derivations ``` ## `nix --version` output ``` $ nix --version nix (Lix, like Nix) 2.93.0-dev System type: x86_64-linux Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/puercopop/.config/nix/nix.conf:/nix/store/4s5qgbm8x6m69nrv9iml2b5lw5l8idyv-plasma-workspace-6.3.4/etc/xdg/nix/nix.conf:/nix/store/2nk3cjv5c75qlicn3j12zpb21d9cm9jv-kglobalacceld-6.3.4/etc/xdg/nix/nix.conf:/nix/store/6gpcrbcdsqx19nyn0swksyqf96297kzd-baloo-6.13.0/etc/xdg/nix/nix.conf:/home/puercopop/.config/kdedefaults/nix/nix.conf:/nix/store/4s5qgbm8x6m69nrv9iml2b5lw5l8idyv-plasma-workspace-6.3.4/etc/xdg/nix/nix.conf:/nix/store/2nk3cjv5c75qlicn3j12zpb21d9cm9jv-kglobalacceld-6.3.4/etc/xdg/nix/nix.conf:/nix/store/6gpcrbcdsqx19nyn0swksyqf96297kzd-baloo-6.13.0/etc/xdg/nix/nix.conf:/home/puercopop/.config/kdedefaults/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/puercopop/.local/share/flatpak/exports/etc/xdg/nix/nix.conf:/var/lib/flatpak/exports/etc/xdg/nix/nix.conf:/home/puercopop/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/puercopop/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/puercopop/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/rzc0zz8y2gwp0nlgi264z0h8p4wll8wj-lix-2.93.0-dev/share ``` ## Additional context <details> <summary>Stack trace</summary> ``` Exception: std::regex_error: Mismatched '(' and ')' in regular expression Stack trace: 0# nix::getStackTrace[abi:cxx11]() in /nix/store/rzc0zz8y2gwp0nlgi264z0h8p4wll8wj-lix-2.93.0-dev/lib/liblixutil.so 1# 0x00007EFD30417B10 in /nix/store/rzc0zz8y2gwp0nlgi264z0h8p4wll8wj-lix-2.93.0-dev/lib/liblixmain.so 2# 0x00007EFD2ECBF1CA in /nix/store/7n3q3rgy5382di7ccrh3r6gk2xp51dh7-gcc-14.2.1.20250322-lib/lib/libstdc++.so.6 3# std::unexpected() in /nix/store/7n3q3rgy5382di7ccrh3r6gk2xp51dh7-gcc-14.2.1.20250322-lib/lib/libstdc++.so.6 4# 0x00007EFD2ECBF447 in /nix/store/7n3q3rgy5382di7ccrh3r6gk2xp51dh7-gcc-14.2.1.20250322-lib/lib/libstdc++.so.6 5# std::__throw_regex_error(std::regex_constants::error_type) in /nix/store/7n3q3rgy5382di7ccrh3r6gk2xp51dh7-gcc-14.2.1.20250322-lib/lib/libstdc++.so.6 6# std::__detail::_Compiler<std::__cxx11::regex_traits<char> >::_Compiler(char const*, char const*, std::locale const&, std::regex_constants::syntax_option_type) in /nix/store/rzc0zz8y2gwp0nlgi264z0h8p4wll8wj-lix-2.93.0-dev/lib/liblixutil.so 7# std::__cxx11::basic_regex<char, std::__cxx11::regex_traits<char> >::_M_compile(char const*, char const*, std::regex_constants::syntax_option_type) in /nix/store/rzc0zz8y2gwp0nlgi264z0h8p4wll8wj-lix-2.93.0-dev/lib/liblixutil.so 8# nix::DrvName::matches(nix::DrvName const&) in /nix/store/rzc0zz8y2gwp0nlgi264z0h8p4wll8wj-lix-2.93.0-dev/lib/liblixstore.so 9# 0x000055E2DADC0045 in nix-env 10# 0x000055E2DADB482F in nix-env 11# 0x000055E2DADAD936 in nix-env 12# 0x000055E2DAC6656B in nix-env 13# 0x000055E2DAD030EB in nix-env 14# 0x000055E2DAD076DD in nix-env 15# nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<void ()>) in /nix/store/rzc0zz8y2gwp0nlgi264z0h8p4wll8wj-lix-2.93.0-dev/lib/liblixmain.so 16# 0x000055E2DAD06F9B in nix-env 17# 0x00007EFD2E82A47E in /nix/store/vbrdc5wgzn0w1zdp10xd2favkjn5fk7y-glibc-2.40-66/lib/libc.so.6 18# __libc_start_main in /nix/store/vbrdc5wgzn0w1zdp10xd2favkjn5fk7y-glibc-2.40-66/lib/libc.so.6 19# 0x000055E2DAC2F6C5 in nix-env Aborted (core dumped) ``` </details>
Owner

the crash has been fixed in main, and the search being rejected is a feature (not a bug) dating back to 2014: nix-env uses regular expressions to match derivation names, * is merely special syntax to match all names (and not an indication that we search by globs). busted, but ancient

the crash has been fixed in main, and the search being rejected is a feature (not a bug) dating back to 2014: nix-env uses regular expressions to match derivation names, `*` is merely special syntax to match all names (and not an indication that we search by globs). busted, but ancient
pennae added
docs
and removed
bug
labels 2025-04-28 20:12:56 +00:00

This also seems to happen in nix profile upgrade:

$ nix profile upgrade '*'
Lix crashed. This is a bug. We would appreciate if you report it along with what caused it at https://git.lix.systems/lix-project/lix/i
ssues with the following information included:

Exception: std::regex_error: Mismatched '(' and ')' in regular expression
Stack trace:
 0# nix::printStackTrace() in /nix/store/m9x3y8acqnm2jvn2papmq6bl5z1qpfck-lix-2.92.0/lib/liblixutil.so
 1# 0x00007FF03F8FD766 in /nix/store/m9x3y8acqnm2jvn2papmq6bl5z1qpfck-lix-2.92.0/lib/liblixmain.so
 2# 0x00007FF03F5F820A in /nix/store/ybjcla5bhj8g1y84998pn4a2drfxybkv-gcc-13.3.0-lib/lib/libstdc++.so.6
 3# 0x00007FF03F5F8275 in /nix/store/ybjcla5bhj8g1y84998pn4a2drfxybkv-gcc-13.3.0-lib/lib/libstdc++.so.6
 4# nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<void ()
>) in /nix/store/m9x3y8acqnm2jvn2papmq6bl5z1qpfck-lix-2.92.0/lib/liblixmain.so
 5# 0x000055C695AEC29B in nix
 6# 0x00007FF03F34827E in /nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6
 7# __libc_start_main in /nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6
 8# 0x000055C695A40D15 in nix

Aborted (core dumped)

I don't know how to easily get lix main to test if the above mentioned fix also fixes it.

This also seems to happen in `nix profile upgrade`: ```console $ nix profile upgrade '*' Lix crashed. This is a bug. We would appreciate if you report it along with what caused it at https://git.lix.systems/lix-project/lix/i ssues with the following information included: Exception: std::regex_error: Mismatched '(' and ')' in regular expression Stack trace: 0# nix::printStackTrace() in /nix/store/m9x3y8acqnm2jvn2papmq6bl5z1qpfck-lix-2.92.0/lib/liblixutil.so 1# 0x00007FF03F8FD766 in /nix/store/m9x3y8acqnm2jvn2papmq6bl5z1qpfck-lix-2.92.0/lib/liblixmain.so 2# 0x00007FF03F5F820A in /nix/store/ybjcla5bhj8g1y84998pn4a2drfxybkv-gcc-13.3.0-lib/lib/libstdc++.so.6 3# 0x00007FF03F5F8275 in /nix/store/ybjcla5bhj8g1y84998pn4a2drfxybkv-gcc-13.3.0-lib/lib/libstdc++.so.6 4# nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::function<void () >) in /nix/store/m9x3y8acqnm2jvn2papmq6bl5z1qpfck-lix-2.92.0/lib/liblixmain.so 5# 0x000055C695AEC29B in nix 6# 0x00007FF03F34827E in /nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6 7# __libc_start_main in /nix/store/wn7v2vhyyyi6clcyn0s9ixvl7d4d87ic-glibc-2.40-36/lib/libc.so.6 8# 0x000055C695A40D15 in nix Aborted (core dumped) ``` I don't know how to easily get `lix` `main` to test if the above mentioned fix also fixes it.
Owner

yep, that one is also fixed in main.

yep, that one is also fixed in main.
Owner

closing as completed since this hasn't happened in a while

closing as completed since this hasn't happened in a while
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
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#813
No description provided.