30 Jan 2025 |
Robert Hensing (roberth) | iirc the cache of parsed files is not released along with the eval state. This is usually not an issue, because it just dies with the process, but this could be improved | 12:00:43 |
Robert Hensing (roberth) | shouldn't be necessary if you're doing everything on the main thread | 12:01:09 |
Leonardo Santiago | In reply to @roberthensing:matrix.org do you also call nix_gc_now() ? wasn't, but even if I do, nothing changes, the behavior is the same | 13:05:28 |
Leonardo Santiago | In reply to @roberthensing:matrix.org iirc the cache of parsed files is not released along with the eval state. This is usually not an issue, because it just dies with the process, but this could be improved but its reallocated when a new eval state is instantiated | 19:48:29 |
Leonardo Santiago | In reply to @roberthensing:matrix.org iirc the cache of parsed files is not released along with the eval state. This is usually not an issue, because it just dies with the process, but this could be improved but is it allocated again once a new evalstate is instantiated? | 19:49:07 |
31 Jan 2025 |
| raboof changed their display name from raboof to raboof@FOSDEM. | 23:54:45 |
1 Feb 2025 |
| @mark_great:matrix.org joined the room. | 04:07:37 |
| NixOS Moderation Bot banned @mark_great:matrix.org (<no reason supplied>). | 04:07:37 |
2 Feb 2025 |
| pbsds changed their display name from pbsds to pbsds (FOSDEM). | 16:04:09 |
| raboof changed their display name from raboof@FOSDEM to raboof. | 22:17:50 |
3 Feb 2025 |
| pbsds changed their display name from pbsds (FOSDEM) to pbsds. | 16:25:40 |
7 Feb 2025 |
| @ekaov:matrix.org joined the room. | 20:38:49 |
| @ekaov:matrix.org left the room. | 21:18:06 |
| @terrorjack:matrix.terrorjack.com left the room. | 22:28:08 |
| terrorjack joined the room. | 22:45:43 |
8 Feb 2025 |
| terrorjack set a profile picture. | 02:24:32 |
| terrorjack removed their profile picture. | 02:25:07 |
12 Feb 2025 |
| Marcel joined the room. | 17:20:19 |
| @idioticself55:matrix.org left the room. | 22:24:37 |
13 Feb 2025 |
| sodiboo joined the room. | 20:54:39 |
sodiboo | in [nix_create_external_value ](https://hydra.nixos.org/build/289480061/download/1/html/group__Externals.html#ga3e2edcbbd07dc5c34509de1d7a9773a7), the API takes a pointer void* v in, and this is basically called user_data in most contexts. I get that the returned ExternalValue* is owned by the nix evaluator, but what about my void* v ? obviously Nix doesn't know how to free this, so i'd expect to see a free callback in [NixCExternalValueDesc ](https://hydra.nixos.org/build/289480061/download/1/html/structNixCExternalValueDesc.html#details), but there is no such function.
i also couldn't easily find any way to detect when a value, in general, is freed (why would there be? only matters for external). so i don't know how my value will ever be freed.
am i just meant to leak my void* v ? | 23:00:24 |
Robert Hensing (roberth) | This seems to be an omission in both the evaluator implementation and in the C API for it. A virtual destructor does exist for ExternalValueBase , but since Value relies entirely on GC and mkExternal doesn't register a finalizer, it seems that this destructor is never called.
It's worth noting that the GC used by Nix can not guarantee that finalizers are called in the first place, as it is a conservative GC, so it is best not to rely on finalization. (Also GC will not run before the process exits, unless e.g. it's the Nix CLI and NIX_SHOW_STATS=1)
Nonetheless, it should be added, because release a resource most of the time, or even sometimes, is better than never.
I'm a bit wary of adding it without ever calling it, because that will cause untested code to start running in the future, which could be a huge surprise when it starts causing crashes etc. So either the whole thing needs to be implemented correctly and/or we add a test utility that forces the finalization, just for the purpose of unit testing.
| 23:39:14 |
Robert Hensing (roberth) | I've opened https://github.com/NixOS/nix/issues/12470 | 23:57:22 |
14 Feb 2025 |
sodiboo | also, I noticed the equality function does not take a value descriptor for other . I guess that's because most programs won't have multiple external types. I also happen to be using Rust, so ultimately my void* v will be something like dyn Any or a wrapper containing an Any ; so naturally I can use that to check type identity. but it is also possible to load multiple plugins, right? what if several add external types? then I have no idea what the other value has for a type. is the value descriptor checked for equality/identity first? that's the only reasonable way this API makes sense, and it's consistent with the documented behavior of not being equal if the other value is of a primitive type. but it's not documented that the equality does any such check before invoking the callback. | 05:26:15 |
sodiboo | actually, for that matter, it looks like it's impossible to query an external value's type, in general, to check if it belongs to "this library" or not. guess i just have to pray that it is, indeed, part of my library? | 08:10:09 |
Robert Hensing (roberth) | Seems to be just an oversight. I'd be happy to accept PRs for these things, or even issues to track in the C API milestone | 08:53:42 |
sodiboo | yeah i guess that's why it's not like, stable yet, lol. | 09:17:35 |
Robert Hensing (roberth) | The original contributor for the C API tried their best, but their use case did not include externals. We could strip out the externals and call it stable if you prefer, or we could accept the status quo, or we could accept contributions. I think we're going for the latter, but we could change our strategy | 16:21:15 |
15 Feb 2025 |
| BenjB83 joined the room. | 10:16:44 |
| BenjB83 changed their display name from BenjamÃn Buske to BenjB83. | 10:43:21 |