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

Stack overflow: stack trace and nix debugger support #8879

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

roberth
Copy link
Member

@roberth roberth commented Aug 29, 2023

Motivation

note
This is distinct from infinite recursion errors, which are already handled properly.

Try it with for example:

nix run github:hercules-ci/nix/stack-overflow -- build .#my-package

Provide means to solve stack overflows in Nix code.

  • Stack trace
  • Launch the debugger

TODO:

  • solve the TODOs in the code. (Sorry for the low effort, as I had to write this from my not so great backup laptop for unrelated reasons)
  • figure out what's the deal with frameOnly. If I don't comment it out, the trace just stops! Understand frame traces #8906
  • add test
  • support coroutines and test with overflow in source filter

Context

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
  • documentation in the internal API docs
  • 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 added a commit to hercules-ci/nix that referenced this pull request Sep 3, 2023
Solves 1/3 of the infinite recursion at unknown location meme.
See NixOS#8879 for ensuring we always have a trace (for stack overflows)
We might want to re-add this for finding missing location info
*while hacking on that problem only*.
@Fuuzetsu
Copy link
Member

I just want to say "thank you"! I managed to get a stack overflow using this patch. I had to set doCheck = false but other than that it seems to work for me!

@yajo
Copy link
Contributor

yajo commented Oct 16, 2023

I'm still not being able to diagnose my endless recursion. I set doCheck = false in flake.nix and ran eval against the flake where I have the problem, using nix from this PR. Exit code 1. Logs: nix-log.txt (I think those aren't very helpful).

@yajo
Copy link
Contributor

yajo commented Oct 16, 2023

I also tested with a publicly reproducible case: #6361 (comment)

Still unhelpful: nix-log.txt

@Fuuzetsu
Copy link
Member

I also tested with a publicly reproducible case: #6361 (comment)

Still unhelpful: nix-log.txt

I'm able to confirm that it indeed doesn't seem to work for this case. Maybe something about import from derivation..? Who knows.

@roberth
Copy link
Member Author

roberth commented Oct 17, 2023

That probably happens because source filtering happens on a coroutine stack instead of the main thread stack.
Their stack protection pages should also be included. Added to TODO.

@roberth roberth added bug error-messages Confusing messages and better diagnostics language The Nix expression language; parser, interpreter, primops, evaluation, etc labels Dec 18, 2023
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
3 participants