aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/eval.cc
AgeCommit message (Collapse)Author
2020-05-28Merge branch 'master' of github.com:NixOS/nix into enum-classCarlo Nucera
2020-05-26Merge remote-tracking branch 'origin/master' into enum-FileIngestionMethodCarlo Nucera
2020-04-18Merge pull request #3502 from NixOS/more-posDomen Kožar
pass Pos to forceValue to improve infinite recursion error
2020-04-16Add function to allocate a Value in traceable memoryEelco Dolstra
2020-04-16pass Pos to forceValue to improve infinite recursion errorDomen Kožar
2020-04-09Attach pos to if expression errorsDomen Kožar
2020-04-08datatransfer.{cc,hh} -> filetransfer.{cc,hh}Nikola Knezevic
2020-04-08Rename src/lib/download.* to src/lib/datatransfer.*Nikola Knezevic
2020-03-29Replace some `bool recursive` with a new `FileIngestionMethod` enumJohn Ericson
2020-03-29Use `enum struct` and drop prefixesJohn Ericson
This does a few enums; the rest will be gotten in subsequent commits.
2020-01-13Tweak error messageEelco Dolstra
2020-01-11libexpr: show expression in assertion errorsDaiderd Jordan
Includes the expression of the condition in the assertion message if the assertion failed, making assertions much easier to debug. eg. error: assertion (withPython -> (python2Packages != null)) failed at pkgs/tools/security/nmap/default.nix:11:1
2020-01-05Hide FunctionCallTrace constructor/destructorEelco Dolstra
This prevents them from being inlined. On gcc 9, this reduces the stack size needed for nix-instantiate '<nixpkgs>' -A texlive.combined.scheme-full --dry-run from 12.9 MiB to 4.8 MiB.
2019-12-10Make the Store API more type-safeEelco Dolstra
Most functions now take a StorePath argument rather than a Path (which is just an alias for std::string). The StorePath constructor ensures that the path is syntactically correct (i.e. it looks like <store-dir>/<base32-hash>-<name>). Similarly, functions like buildPaths() now take a StorePathWithOutputs, rather than abusing Path by adding a '!<outputs>' suffix. Note that the StorePath type is implemented in Rust. This involves some hackery to allow Rust values to be used directly in C++, via a helper type whose destructor calls the Rust type's drop() function. The main issue is the dynamic nature of C++ move semantics: after we have moved a Rust value, we should not call the drop function on the original value. So when we move a value, we set the original value to bitwise zero, and the destructor only calls drop() if the value is not bitwise zero. This should be sufficient for most types. Also lots of minor cleanups to the C++ API to make it more modern (e.g. using std::optional and std::string_view in some places).
2019-12-10EvalState::callFunction(): Make FunctionCallTrace use less stack spaceEelco Dolstra
The FunctionCallTrace object consumes a few hundred bytes of stack space, even when tracing is disabled. This was causing stack overflows: $ nix-instantiate '<nixpkgs> -A texlive.combined.scheme-full --dry-run error: stack overflow (possible infinite recursion) This is with the default stack size of 8 MiB. Putting the object on the heap reduces stack usage to < 5 MiB.
2019-12-05Move #includeEelco Dolstra
(cherry picked from commit 8beedd44861d1fe7208609ee8d231ca1c02dedf6)
2019-11-28Remove builtins.valueSizeEelco Dolstra
Fixes #3246.
2019-11-25Ensure enough space in attrset bindings when using both __overrides and ↵Puck Meerburg
dynamic attributes
2019-11-22Turn NIX_PATH into a config settingEelco Dolstra
This allows it to be set in nix.conf.
2019-11-22Provide a default value for NIX_PATHEelco Dolstra
2019-11-22getEnv(): Return std::optionalEelco Dolstra
This allows distinguishing between an empty value and no value.
2019-11-11Merge pull request #3219 from Ericson2314/semicolonsEelco Dolstra
Fix extra semicolons warnings
2019-11-10Remove unneeded semicolonsJohn Ericson
2019-10-27Merge branch 'tojson-tostring-fix' of https://github.com/mayflower/nixEelco Dolstra
2019-10-27builtins.toJSON: fix __toString usageRobin Gloster
2019-10-09OCD performance fix: {find,count}+insert => insertEelco Dolstra
2019-08-14Track function start and ends for flame graphsGraham Christensen
With this patch, and this file I called `log.py`: #!/usr/bin/env nix-shell #!nix-shell -i python3 -p python3 --pure import sys from pprint import pprint stack = [] timestack = [] for line in open(sys.argv[1]): components = line.strip().split(" ", 2) if components[0] != "function-trace": continue direction = components[1] components = components[2].rsplit(" ", 2) loc = components[0] _at = components[1] time = int(components[2]) if direction == "entered": stack.append(loc) timestack.append(time) elif direction == "exited": dur = time - timestack.pop() vst = ";".join(stack) print(f"{vst} {dur}") stack.pop() and: nix-instantiate --trace-function-calls -vvvv ../nixpkgs/pkgs/top-level/release.nix -A unstable > log.matthewbauer 2>&1 ./log.py ./log.matthewbauer > log.matthewbauer.folded flamegraph.pl --title matthewbauer-post-pr log.matthewbauer.folded > log.matthewbauer.folded.svg I can make flame graphs like: http://gsc.io/log.matthewbauer.folded.svg --- Includes test cases around function call failures and tryEval. Uses RAII so the finish is always called at the end of the function.
2019-04-11Add environment variable NIX_SHOW_SYMBOLS for dumping the symbol tableEelco Dolstra
2019-03-21eval: improve type description for primops and applied primopsLinus Heckemann
This can make type errors a little easier to understand.
2018-12-31EvalState::resetFileCache: clear parse cache as well as eval cacheWill Dietz
Fixes #2546. (at least the basic reproduction I've been testing)
2018-09-05Convert NIX_COUNT_CALLS to JSON tooEelco Dolstra
2018-09-05Log stats to stderrEelco Dolstra
We shouldn't pollute stdout.
2018-09-02remove the old text format outputMichael Bishop
2018-09-01add JSON to NIX_SHOW_STATSMichael Bishop
2018-09-01improve the stats when profilingMichael Bishop
2018-08-03Merge pull request #2326 from aszlig/fix-symlink-leakEelco Dolstra
Fix symlink leak in restricted eval mode
2018-08-03Fix symlink leak in restricted eval modeaszlig
In EvalState::checkSourcePath, the path is checked against the list of allowed paths first and later it's checked again *after* resolving symlinks. The resolving of the symlinks is done via canonPath, which also strips out "../" and "./". However after the canonicalisation the error message pointing out that the path is not allowed prints the symlink target in the error message. Even if we'd suppress the message, symlink targets could still be leaked if the symlink target doesn't exist (in this case the error is thrown in canonPath). So instead, we now do canonPath() without symlink resolving first before even checking against the list of allowed paths and then later do the symlink resolving and checking the allowed paths again. The first call to canonPath() should get rid of all the "../" and "./", so in theory the only way to leak a symlink if the attacker is able to put a symlink in one of the paths allowed by restricted evaluation mode. For the latter I don't think this is part of the threat model, because if the attacker can write to that path, the attack vector is even larger. Signed-off-by: aszlig <aszlig@nix.build>
2018-07-31Merge branch 'prim_mapAttr-fix' of https://github.com/volth/nixEelco Dolstra
2018-07-11Remove unused function printStats2()Eelco Dolstra
Closes #2282.
2018-07-06prim_mapAttrs: `f' must be evaluated lazily to avoid infinite recursionvolth
2018-06-12GC_malloc -> GC_MALLOCEelco Dolstra
This makes it possible to build with -DGC_DEBUG.
2018-06-12Don't scan for roots in dynamic librariesEelco Dolstra
This reduces the risk of object liveness misdetection. For example, Glibc has an internal variable "mp_" that often points to a Boehm object, keeping it alive unnecessarily. Since we don't store any actual roots in global variables, we can just disable data segment scanning. With this, the max RSS doing 100 evaluations of nixos.tests.firefox.x86_64-linux.drvPath went from 718 MiB to 455 MiB.
2018-06-12Add temporary statsEelco Dolstra
2018-06-12Cache parse treesEelco Dolstra
This prevents EvalState::resetFileCache() from parsing everything all over again.
2018-06-12Remove duplicate definition of allocBytes()Eelco Dolstra
2018-05-30Fix static assertion failure on 32-bit systemsEelco Dolstra
2018-05-30Move evaluator-specific settings out of libstoreEelco Dolstra
2018-05-26eval.cc: add message to static_assert, message can be omitted w/c++17Will Dietz
2018-05-22Make Env self-describingEelco Dolstra
If the Env denotes a 'with', then values[0] may be an Expr* cast to a Value*. For code that generically traverses Values/Envs, it's useful to know this.
2018-05-22Memoise checkSourcePath()Eelco Dolstra
This prevents hydra-eval-jobs from statting the same files over and over again.