Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eval: Fix crash on missing printValue tBlackhole case #8148

Merged

Conversation

roberth
Copy link
Member

@roberth roberth commented Apr 1, 2023

Motivation

Very motivated. I hate crashes.

This fixes a bug.

Context

Fixes #8119

Checklist for maintainers

Maintainers: tick if completed or explain if not relevant

  • agreed on idea
  • agreed on implementation strategy
  • tests, as appropriate
    • functional tests - tests/**.sh
    • unit tests - src/*/tests
    • integration tests - tests/nixos/*
  • documentation in the manual
  • code and comments are self-explanatory
  • commit message explains why the change was made
  • new feature or incompatible change: updated release notes

Priorities

Add 👍 to pull requests you find important.

@roberth roberth added bug language The Nix expression language; parser, interpreter, primops, evaluation, etc labels Apr 1, 2023
@roberth roberth requested a review from edolstra as a code owner April 1, 2023 20:16
@github-actions github-actions bot added the with-tests Issues related to testing. PRs with tests have some priority label Apr 1, 2023
src/libexpr/eval.cc Outdated Show resolved Hide resolved
@@ -173,7 +173,11 @@ void Value::print(const SymbolTable & symbols, std::ostream & str,
case tFloat:
str << fpoint;
break;
case tBlackhole:
str << "«potential infinite recursion»";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "potential" can be dropped, since in eval output this denotes an actual infinite recursion.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've explained it in a comment:

        // Although we know for sure that it's going to be an infinite recursion
        // when this value is accessed _in the current context_, it's likely
        // that the user will misinterpret a simpler «infinite recursion» output
        // as a definitive statement about the value, while in fact it may be
        // a valid value after `builtins.trace` and perhaps some other steps
        // have completed.

@roberth roberth force-pushed the fix-issue-8119-printValue-tBlackhole-abort branch from 5279b52 to fb57734 Compare April 3, 2023 13:29
@roberth roberth force-pushed the fix-issue-8119-printValue-tBlackhole-abort branch from fb57734 to 1c55544 Compare April 3, 2023 13:32
@roberth roberth enabled auto-merge April 3, 2023 13:34
@roberth roberth merged commit f3a6de6 into NixOS:master Apr 3, 2023
@yorickvP
Copy link
Contributor

yorickvP commented May 8, 2023

also fixes this one:

❯ cat flake.nix 
{
  outputs = { self }: { x = builtins.trace self { }; };
}
❯ nix build .#x
Aborted (core dumped)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug language The Nix expression language; parser, interpreter, primops, evaluation, etc with-tests Issues related to testing. PRs with tests have some priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Aborted (core dumped) trying to builtins.trace at specialArgs
3 participants