NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
11.45k stars 1.44k forks source link

C API: `nix_alloc_primop`'s `user_data` leaks #10976

Open roberth opened 4 days ago

roberth commented 4 days ago

Describe the bug

We don't have a way to add a finalizer to release whatever is in the user_data field.

Steps To Reproduce

Read nix_alloc_primop signature. It can't release the user_data.

Expected behavior

Nix provides a way to set a finalizer, either in the nix_alloc_primop function (or variant of it), or we can nix_primop_set_finalizer immediately after.

nix-env --version output

Additional context

This is most relevant when allocating many primops.

This is less relevant when the primops are only registered as builtins, in which case you could tie the lifetime of the user_data to the thing that holds your EvalState.

Priorities

Add :+1: to issues you find important.