screenpipe icon indicating copy to clipboard operation
screenpipe copied to clipboard

[bug] SIGSEGV in clipboard-capture thread during autoreleasePoolPop (v2.4.12)

Open uri-gil opened this issue 7 months ago • 0 comments

Summary

screenpipe-app crashes with EXC_BAD_ACCESS (SIGSEGV) / KERN_INVALID_ADDRESS in the clipboard-capture thread during objc_autoreleasePoolPop. Classic Objective-C lifetime bug — the autorelease pool is draining into an already-freed object.

Environment

  • Version: 2.4.12 (dev-signed build, bundle id screenpi.pe.dev)
  • macOS: 26.4.1 (25E253) — Mac16,5 (M4 Max, 128 GB)
  • Uptime at crash: ~10h 17m (launch 12:09:05, crash 22:26:32 local)
  • Displays during session: 4 (1× UWQHD, 1× built-in Retina, 2× QHD)

Reproduction

Not yet isolated — crash occurred after ~10h of normal use with heavy clipboard activity. A repeatable minimal repro is still needed; the shape of the bug suggests it's triggered by a specific clipboard type or NSPasteboard item that the capture code retains incorrectly.

Triggering thread (158, clipboard-capture)

0  libobjc.A.dylib                 objc_release + 16
1  libobjc.A.dylib                 AutoreleasePoolPage::releaseUntil + 204
2  libobjc.A.dylib                 objc_autoreleasePoolPop + 244
3  screenpipe-app                  <clipboard capture code>  (offset 15201088)
4  screenpipe-app                  <clipboard capture code>  (offset 15197728)
5  screenpipe-app                  <tokio task entry>        (offset 19892820)
6  libsystem_pthread.dylib         _pthread_start + 136
7  libsystem_pthread.dylib         thread_start + 8

Exception:

Exception Type:    EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x000034eedea17530
Termination Reason: Namespace SIGNAL, Code 11, Segmentation fault: 11

The faulting address 0x34eedea17530 is unmapped — VM Region Info: is not in any region. UNUSED SPACE AT END. That pattern is consistent with "released the object; the pool still holds a pointer; pop tries to release it again."

Suspected cause

Something owned by the clipboard-capture thread is being Obj-C-released outside the thread's autorelease pool, then objc_autoreleasePoolPop re-releases a pointer that was already freed. Candidates:

  • An NSPasteboardItem or pasteboard NSString read without the proper autoreleasepool { ... } block on that worker thread.
  • A cached pasteboard object held across drain cycles (e.g., to diff for changes) whose retain/release balance is off by one.
  • FFI: a Rust-side structure that frees an Obj-C object it doesn't own.

The presence of many long-running clipboard-capture threads in the dump (Thread 69, 90, 111, 113, 115, 117, 119, 121, 123, 126, 154, 162, 2106467, 2298404, 2300125, 2301375, 2302085, 3757887…) suggests a thread-per-capture or thread-per-pasteboard-observer model; any one of them draining an autorelease pool with a dangling pointer would produce this stack.

Non-goals / context

  • Not related to PR #3017 (vision allowlist reconcile) — crashing thread is clipboard-capture, and the running binary is the pre-#3017 build dated 2026-04-19.
  • Filing as a separate issue so the vision fix and this clipboard lifetime bug stay in their own threads.

What would help next

  • Anyone with a repeatable repro (specific app / clipboard content type).
  • A pointer to the exact clipboard-capture source location at binary offset 15197728 / 15201088 — happy to dig in with guidance on which module to look at.

Full crash report available on request (109 kB, 176 threads) — omitted here to keep the issue readable.

uri-gil avatar Apr 20 '26 20:04 uri-gil