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

Segfault when displaying a self-referencing attrset as JSON #12289

Open
2 tasks done
hgl opened this issue Jan 19, 2025 · 2 comments
Open
2 tasks done

Segfault when displaying a self-referencing attrset as JSON #12289

hgl opened this issue Jan 19, 2025 · 2 comments
Labels
bug idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. language The Nix expression language; parser, interpreter, primops, evaluation, etc

Comments

@hgl
Copy link

hgl commented Jan 19, 2025

Describe the bug

When displaying a self-referencing attrset as JSON, it would be great if nix could show an error message along with the stack.

Steps To Reproduce

test.nix

let
  a = {
    b = a;
  };
in
a
$ nix eval --json -f test.nix .
fish: Job 1, 'nix eval --json -f test.nix .' terminated by signal SIGSEGV (Address boundary error)

Expected behavior

An error message showing the stack

Metadata

Additional context

Checklist


Add 👍 to issues you find important.

@hgl hgl added the bug label Jan 19, 2025
@tomberek tomberek added good first issue Quick win for first-time contributors idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. and removed good first issue Quick win for first-time contributors labels Jan 22, 2025
@roberth roberth added the language The Nix expression language; parser, interpreter, primops, evaluation, etc label Jan 22, 2025
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-01-22-nix-team-meeting-minutes-210/59239/1

@llakala
Copy link
Contributor

llakala commented Jan 22, 2025

Oh hey, I just found out about this in #11576!

However, I do get an error message with the same setup:

❯ nix eval --json -f test.nix .
error: stack overflow (possible infinite recursion)

And, inlining the expression rather than storing it in a file, same result:

❯ nix eval --json --expr "let a = { b = a; }; in a"
error: stack overflow (possible infinite recursion)

I did some binary search on old Nix versions (see my comment in the linked issue). But TLDR, even though the behavior changed between 2.11 and 2.12, in both cases, I get a different output from what you got. Maybe it's a flaky output based on the amount of cache you have or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. language The Nix expression language; parser, interpreter, primops, evaluation, etc
Projects
None yet
Development

No branches or pull requests

5 participants