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

Impossible to trace error: stack overflow (possible infinite recursion) #6361

Open
yajo opened this issue Apr 5, 2022 · 7 comments · May be fixed by #8879
Open

Impossible to trace error: stack overflow (possible infinite recursion) #6361

yajo opened this issue Apr 5, 2022 · 7 comments · May be fixed by #8879
Labels
bug error-messages Confusing messages and better diagnostics language The Nix expression language; parser, interpreter, primops, evaluation, etc

Comments

@yajo
Copy link
Contributor

yajo commented Apr 5, 2022

Describe the bug

Something I've done started producing an infinite recursion. Nix just fails, but there's no stack trace, so AFAIK there's no possible way to know what triggers the problem.

Steps To Reproduce

nix flake check --show-trace 'gitlab:moduon/mrchef?rev=7f6177504daaa74d1b8dc64b256fbf15866efb3a'

Expected behavior

I'm passing --show-trace, so there should be a trace.

nix-env --version output
nix-env (Nix) 2.7.0

Additional context

I'm building a python app to manage git meta-repositories. Sort of a better replacement for git-submodules.

I asked in https://discourse.nixos.org/t/how-to-debug-infinite-recursion/18470?u=yajo but so far I've started to believe this is a bug in nix.

The ref above points to https://gitlab.com/moduon/mrchef/-/merge_requests/1 where I isolated the test case that reproduces this problem.

Edit: the final fix was nix-community/poetry2nix#585. I could have found that in minutes, not days, if I had a proper stack trace.

@moduon MT-83

@yajo yajo added the bug label Apr 5, 2022
@Artturin
Copy link
Member

Artturin commented Apr 7, 2022

Try show-trace with #6204

@yajo
Copy link
Contributor Author

yajo commented Apr 8, 2022

Still unhelpful 😕

> nix run 'github:NixOs/nix/refs/pull/6204/head' -- flake check --show-trace 'gitlab:moduon/mrchef?rev=7f6177504daaa74d1b8dc64b256fbf15866efb3a'
warning: unknown flake output 'lib'
[0/1 built] checking flake output 'checks'error: stack overflow (possible infinite recursion)

Not a clue on where the infinite recursion happened.

@roberth
Copy link
Member

roberth commented Nov 12, 2022

These are detected overflows of the C++ stack.
We could potentially use the heap to store more of the Nix evaluation stack, turning some of these errors into successful evaluations, and others into diverging programs that either run out of heap space, or, if we decide to, error out because of a more artificial limit that isn't as low as the C++ stack's limit.

@stale stale bot removed the stale label Nov 12, 2022
@roberth
Copy link
Member

roberth commented Nov 12, 2022

If we decide to implement our own limit on the stack size, we can throw a proper exception that can return a proper stack trace or start the debugger.

@roberth roberth added the error-messages Confusing messages and better diagnostics label Nov 12, 2022
@roberth roberth added the language The Nix expression language; parser, interpreter, primops, evaluation, etc label Dec 13, 2022
@stale stale bot added the stale label Jun 18, 2023
@thufschmitt thufschmitt removed the stale label Jun 23, 2023
@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/2023-06-22-nix-team-meeting-minutes-65/29643/1

@yajo
Copy link
Contributor Author

yajo commented Oct 9, 2023

Is there any progress on this issue? Diagnosing the source of these kind of errors is extremely frustrating. I'm having another one and I don't know even where to start.

@roberth
Copy link
Member

roberth commented Oct 10, 2023

@yajo There actually is! You could try #8879

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug error-messages Confusing messages and better diagnostics language The Nix expression language; parser, interpreter, primops, evaluation, etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants