Skip to content

Bug: SIGSEGV in PipeWire MemFd buffer handling via portal ScreenCast #43

@lamco-office

Description

@lamco-office

Summary

Server crashes with SIGSEGV when receiving MemFd-type buffers through the PipeWire portal ScreenCast capture path. The crash occurs because PipeWire's MAP_BUFFERS auto-mapping can produce stale pointers for MemFd buffers received via portal FD connections.

Affected versions

v1.4.2 and earlier (when using portal ScreenCast capture path)

Who is affected

Users on compositors where the portal backend provides MemFd buffers rather than DmaBuf. This is most commonly observed with XDPH (Hyprland's XDG Desktop Portal backend) on PipeWire 1.6.x, since XDPH defaults to MemFd unless the client advertises DmaBuf modifier support.

Affected configuration:

  • Capture path: portal ScreenCast → PipeWire (not wlr-screencopy)
  • Buffer type: MemFd (PipeWire SPA_DATA_MemFd, type 2)
  • Trigger: stream lifecycle event (disconnect, renegotiation) that invalidates auto-mapped pointers

NOT affected:

  • Users on the wlr-screencopy capture path (bypasses PipeWire entirely)
  • Users receiving DmaBuf buffers (type 3) — these already use manual mmap
  • Users receiving MemPtr buffers (type 1) — direct pointer, no mapping involved

Root cause

PipeWire's MAP_BUFFERS stream flag auto-mmaps MemFd buffers at stream setup time. When the portal FD connection experiences lifecycle events (disconnect, renegotiation), the internal clear_buffers() calls munmap() but the buffer's data pointer field is not nulled. The libspa data() accessor only checks for null — it returns this stale, unmapped pointer as valid. Attempting to memcpy from it triggers SIGSEGV.

Status

Fixed in lamco-pipewire 0.3.2. Pending next server release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1-highImportant for next releasebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions