The author reflects on the challenges of using Garbage Collection (GC) with explicit ownership, using the example of creating a Guile binding for Harfbuzz. The issue arises with handling refcounted sequences of bytes (blobs) and ensuring their memory is not accessed after being collected. The author points out the pitfalls of relying on finalizers in languages like LuaJIT, highlighting the need for a deep understanding of compiler behavior or manual lifetime extension strategies. They suggest that maintaining such systems may require avoiding updates or building close relationships with GC and compiler maintainers. For further insights, they recommend Hans Boehm’s work on the topic.
https://wingolog.org/archives/2024/02/26/on-the-impossibility-of-composing-finalizers-and-ffi