Skip to content

Unexpected unsafeGetAttrPos output depending on attrset merge order #13166

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

Open
2 tasks done
numinit opened this issue May 11, 2025 · 1 comment
Open
2 tasks done

Unexpected unsafeGetAttrPos output depending on attrset merge order #13166

numinit opened this issue May 11, 2025 · 1 comment
Labels

Comments

@numinit
Copy link

numinit commented May 11, 2025

Describe the bug

Depending on the relative ordering of a call to unsafeGetAttrPos to an attrset merge on the declaring attrset, the output of unsafeGetAttrPos may be different.

Tested on:

  • nix (Nix) 2.24.13
  • nix (Lix, like Nix) 2.91.1

Steps To Reproduce

Run https://gist.github.com/numinit/60c69b6873812c5e51c307f19cbb104b on nixpkgs master.

Expected behavior

The attribute position is unchanged regardless of where the call to unsafeGetAttrPos is (since it's a variable in the scope, after all), and refers to the original position. Right now it looks like the position is mutated!

The critical line is // attrs.meta or { }. If the call to unsafeGetAttrPos is moved afterwards, it misbehaves and returns the position in the current file, instead of the position in the original definition of attrs.

Metadata

nix-env (Nix) 2.24.13

Additional context

Checklist


Add 👍 to issues you find important.

@numinit numinit added the bug label May 11, 2025
@numinit numinit changed the title Unexpected unsafeGetAttrPos output depending on attrset merge order in nixpkgs Unexpected unsafeGetAttrPos output depending on attrset merge order May 11, 2025
@numinit
Copy link
Author

numinit commented May 11, 2025

Other things I've tried:

  • Toy example: not reproducible. Something about the complexity of nixpkgs is involved.
  • GC_DONT_GC=1: still reproducible, may rule out GC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant