libghostty: IOSurfaceLayer display callback not cleared on renderer deinit (use-after-free after ghostty_surface_free) #13242
SummaryWhen embedding libghostty on macOS, the renderer's CALayer keeps a raw function pointer into freed memory after Crash signatureFaulting thread: Root causeVerified against
Ghostty.app doesn't hit this because it frees the surface after its view (and layer) has left the hierarchy. Embedders that free while the view is still mounted hit it reliably. Reproduction (embedding scenario)
FixClearing the callback during renderer teardown resolves it: pub fn deinit(self: *Metal) void {
+ self.layer.setDisplayCallback(null, null);
self.queue.release();
self.device.release();
self.layer.release();
}We've been running this patch in a production embedder (Conterm) with no regressions. Happy to open a PR if this is the right shape. |
Replies: 1 comment
|
Fixed on main |
Fixed on main