Skip to content

fix: Cmd+V crashes app (NSPasteboard EXC_BAD_ACCESS) #455

Description

@kwannoel

Problem

Pressing Cmd+V crashes the app with a segfault:

EXC_BAD_ACCESS / Segmentation fault: 11
  libobjc.A.dylib: objc_msgSend
  AppKit: -[NSPasteboard _updateTypeCacheIfNeeded]
  WebKit: WebPasteboardProxy::grantAccessToCurrentData
  WebKit: -[WKWebView(WKImplementationMac) paste:]

Root Cause

The app has no native macOS Edit menu. Without it, Cmd+V bypasses the menu system and goes directly through a lower-level AppKit path into WKWebView's paste handler. This races with the clipboard plugin's readImage() call (used for image paste detection), causing a stale pointer dereference in NSPasteboard.

This is a known Tauri/macOS issue (tauri-apps/tauri#2397, tauri-apps/tauri#3395).

Fix

Add a native Edit menu with standard items (Cut, Copy, Paste, Select All) in src-tauri/src/lib.rs:

use tauri::menu::{MenuBuilder, SubmenuBuilder};

let edit_menu = SubmenuBuilder::new(app, "Edit")
    .cut()
    .copy()
    .paste()
    .select_all()
    .build()?;

let menu = MenuBuilder::new(app)
    .item(&edit_menu)
    .build()?;

app.set_menu(menu)?;

This routes Cmd+V through the macOS menu system, which synchronizes NSPasteboard access on the main thread before dispatching to WKWebView. The DOM paste event still fires normally, so existing JS paste handlers (terminal image paste, notes editor) continue to work.

Also fix

log_frontend_error in commands.rs:2098 uses bare eprintln! which panics when stderr is unavailable (orphaned process). Change to let _ = write!() to silently discard errors. (Already implemented on current master, needs commit.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions