“There was an entire class of bug that kept popping up in the Ghostty GTK application that could basically be summed up as: the Zig memory or the GTK memory has been freed, but not both.”

Hashimoto’s team tried to avoid GTK’s GObject system and paid for it with memory bugs. Zig and GTK have different ideas about who owns what memory. The mismatch created a bug category that kept recurring. So they rewrote the whole thing to embrace GObject’s reference counting. Valgrind found only one leak in the Zig code. Most problems were at C API boundaries. Sometimes you fight the framework and sometimes you lose.