## Objective Prevent a use-after-free when a macOS pasteboard wrapper outlives the autorelease pool in which it was created. Pasteboard cached its NSPasteboard and custom zed-text-hash and zed-metadata NSString objects as raw ids. These constructors return autoreleased objects. A later clipboard read could therefore pass a dangling type identifier to dataForType and crash in objc_msgSend. ## Solution - Retain the pasteboard and custom type objects for the Pasteboard lifetime with StrongPtr. - Copy NSData contents into owned Rust byte buffers before the autoreleased data object can expire. - Add a regression test that drains the creation autorelease pool and then accesses the retained custom types. ## Testing - cargo test -p gpui_macos --features runtime_shaders test_custom_types_survive_creation_autorelease_pool --lib - Built an optimized macOS embedder against the patched GPUI checkout. ## Self-Review Checklist: - [x] I have reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks have justifying comments - [x] The content adheres to Zed UI and icon standards; this change has no UI - [x] Tests cover the changed lifetime behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - Fixed a macOS crash that could occur when reading from the clipboard. --- AI Disclosure: I ran into this bug on a project where I'm using GPUI. For my purposes I patched it on my fork I maintain. I had codex (gpt 5.6-sol) send this PR because I think this fix should be upstreamed.
1 file changedLine totals unavailable