Format string error if nix-shell environment contains format string placeholders #533

Closed
opened 2024-09-25 21:57:58 +00:00 by jade · 1 comment
Owner
builtins.derivation {
  name = "evil-kbity";
  system = "x86_64-darwin";
  builder = "/bin/sh";
  args = [ "-c" "> $out" ];
  __structuredAttrs = true;
  env.oops = "lol %s";
}

repro (after some unpublished format string error crashing-harder improvements):

$ nix-shell evil.nix
nix::fmt threw format error. Original format string: '_nix_shell_clean_tmpdir() { command rm -rf %1
%; }; trap _nix_shell_clean_tmpdir EXIT; exitHooks+=(_nix_shell_clean_tmpdir); failureHooks+=(_nix_
shell_clean_tmpdir); [ -n "$PS1" ] && [ -e ~/.bashrc ] && source ~/.bashrc;%2%unset PATH;dontAddDis
ableDepTrack=1;
declare builder='/bin/sh'
declare -A env=(['oops']='lol %s' )
declare name='evil-kbity'
declare -A outputs=(['out']='/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9' )
declare system='x86_64-darwin'

[ -e $stdenv/setup ] && source $stdenv/setup; %3%PATH=%4%:"$PATH"; SHELL=%5%; BASH=%5%; set +e; [ -
n "$PS1" -a -z "$NIX_SHELL_PRESERVE_PROMPT" ] && PS1='\n\[\033[1;32m\][nix-shell:\w]\$\[\033[0m\] '
; if [ "$(type -t runHook)" = function ]; then runHook shellHook; fi; unset NIX_ENFORCE_PURITY; sho
pt -u nullglob; unset TZ; %6%shopt -s execfail;%7%'; number of arguments: 7
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/issues with the following information included:

Exception: boost::wrapexcept<boost::io::bad_format_string>: boost::bad_format_string: format-string
 is ill-formed
Stack trace:
 0# nix::printStackTrace() in /home/jade/lix/lix/outputs/out/lib/liblixutil.so
 1# 0x00007F225F2B7542 in /home/jade/lix/lix/outputs/out/lib/liblixmain.so
 2# 0x00007F225E0BC21A in /nix/store/p44qan69linp3ii0xrviypsw2j4qdcp2-gcc-13.2.0-lib/lib/libstdc++.
so.6
 3# 0x00007F225E0BC285 in /nix/store/p44qan69linp3ii0xrviypsw2j4qdcp2-gcc-13.2.0-lib/lib/libstdc++.
so.6
 4# 0x000055EC0E228A2B in nix-shell
 5# 0x000055EC0E222872 in nix-shell
 6# 0x000055EC0E1ABACE in nix-shell
 7# nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<c
har> > const&, std::function<void ()>) in /home/jade/lix/lix/outputs/out/lib/liblixmain.so
 8# 0x000055EC0E1AFE5B in nix-shell
 9# 0x00007F225DE3D10E in /nix/store/dbcw19dshdwnxdv5q2g6wldj6syyvq7l-glibc-2.39-52/lib/libc.so.6
10# __libc_start_main in /nix/store/dbcw19dshdwnxdv5q2g6wldj6syyvq7l-glibc-2.39-52/lib/libc.so.6
11# 0x000055EC0E10B3B5 in nix-shell

zsh: IOT instruction (core dumped)  nix-shell repro.nix

nix (Lix, like Nix) 2.92.0-dev-pre20240918-79246a3

```nix builtins.derivation { name = "evil-kbity"; system = "x86_64-darwin"; builder = "/bin/sh"; args = [ "-c" "> $out" ]; __structuredAttrs = true; env.oops = "lol %s"; } ``` repro (after some unpublished format string error crashing-harder improvements): ``` $ nix-shell evil.nix nix::fmt threw format error. Original format string: '_nix_shell_clean_tmpdir() { command rm -rf %1 %; }; trap _nix_shell_clean_tmpdir EXIT; exitHooks+=(_nix_shell_clean_tmpdir); failureHooks+=(_nix_ shell_clean_tmpdir); [ -n "$PS1" ] && [ -e ~/.bashrc ] && source ~/.bashrc;%2%unset PATH;dontAddDis ableDepTrack=1; declare builder='/bin/sh' declare -A env=(['oops']='lol %s' ) declare name='evil-kbity' declare -A outputs=(['out']='/1rz4g4znpzjwh1xymhjpm42vipw92pr73vdgl6xs1hycac8kf2n9' ) declare system='x86_64-darwin' [ -e $stdenv/setup ] && source $stdenv/setup; %3%PATH=%4%:"$PATH"; SHELL=%5%; BASH=%5%; set +e; [ - n "$PS1" -a -z "$NIX_SHELL_PRESERVE_PROMPT" ] && PS1='\n\[\033[1;32m\][nix-shell:\w]\$\[\033[0m\] ' ; if [ "$(type -t runHook)" = function ]; then runHook shellHook; fi; unset NIX_ENFORCE_PURITY; sho pt -u nullglob; unset TZ; %6%shopt -s execfail;%7%'; number of arguments: 7 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/issues with the following information included: Exception: boost::wrapexcept<boost::io::bad_format_string>: boost::bad_format_string: format-string is ill-formed Stack trace: 0# nix::printStackTrace() in /home/jade/lix/lix/outputs/out/lib/liblixutil.so 1# 0x00007F225F2B7542 in /home/jade/lix/lix/outputs/out/lib/liblixmain.so 2# 0x00007F225E0BC21A in /nix/store/p44qan69linp3ii0xrviypsw2j4qdcp2-gcc-13.2.0-lib/lib/libstdc++. so.6 3# 0x00007F225E0BC285 in /nix/store/p44qan69linp3ii0xrviypsw2j4qdcp2-gcc-13.2.0-lib/lib/libstdc++. so.6 4# 0x000055EC0E228A2B in nix-shell 5# 0x000055EC0E222872 in nix-shell 6# 0x000055EC0E1ABACE in nix-shell 7# nix::handleExceptions(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<c har> > const&, std::function<void ()>) in /home/jade/lix/lix/outputs/out/lib/liblixmain.so 8# 0x000055EC0E1AFE5B in nix-shell 9# 0x00007F225DE3D10E in /nix/store/dbcw19dshdwnxdv5q2g6wldj6syyvq7l-glibc-2.39-52/lib/libc.so.6 10# __libc_start_main in /nix/store/dbcw19dshdwnxdv5q2g6wldj6syyvq7l-glibc-2.39-52/lib/libc.so.6 11# 0x000055EC0E10B3B5 in nix-shell zsh: IOT instruction (core dumped) nix-shell repro.nix ``` `nix (Lix, like Nix) 2.92.0-dev-pre20240918-79246a3`
jade added the
bug
label 2024-09-25 21:57:58 +00:00
jade self-assigned this 2024-09-25 21:58:18 +00:00
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/1959 ("nix-shell: stop using dynamic format strings!!")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/1959", "number": 1959, "kind": "commit message"}], "cl_meta": {"1959": {"change_title": "nix-shell: stop using dynamic format strings!!"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/1959](https://gerrit.lix.systems/c/lix/+/1959) ("nix-shell: stop using dynamic format strings!!")
Sign in to join this conversation.
No milestone
No project
No assignees
2 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#533
No description provided.