Skip to content

Crash on startup with Apple GPU: null pointer in drmModifierName (Asahi Linux) #13407

@fjordnode

Description

@fjordnode

Description

Hyprland 0.54.0 crashes immediately on startup on Apple Silicon (M1) with Asahi Linux. The crash occurs in NFormatUtils::drmModifierName() when drmGetFormatModifierName() returns NULL for an unrecognized Apple GPU DRM modifier.

System Info

  • Device: MacBook Air M1
  • OS: Fedora Asahi Remix 42
  • Kernel: 6.18.10-402.asahi.fc42.aarch64+16k
  • GPU: Apple AGX (via asahi mesa driver)
  • Hyprland: v0.54.0

Crash Backtrace (key frames)

Hyprland received signal 6(ABRT)

#12 | NFormatUtils::drmModifierName[abi:cxx11](unsigned long)
#13 | CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche, ...)
#16 | Hyprutils::Signal::CSignalListener::emitInternal(void*)
#18 | CCompositor::startCompositor()
#19 | main

Root Cause

In src/helpers/Format.cpp line 324, drmGetFormatModifierName(mod) returns NULL for unknown/vendor-specific DRM modifiers (such as those used by the Apple GPU driver). The result is passed directly to std::string constructor which throws std::logic_error on null input.

std::string NFormatUtils::drmModifierName(uint64_t mod) {
    auto        n    = drmGetFormatModifierName(mod);
    std::string name = n;    // <-- crashes when n is NULL
    free(n);
    return name;
}

Note: drmFormatName() just above has the same pattern and could also crash with unknown formats.

Fix

Add a null check:

std::string NFormatUtils::drmModifierName(uint64_t mod) {
    auto        n    = drmGetFormatModifierName(mod);
    std::string name = n ? n : "UNKNOWN";
    free(n);
    return name;
}

This is confirmed working — Hyprland 0.54.0 built from source with this patch starts and runs correctly on Asahi Linux M1.

Log Tail (before crash)

DEBUG from aquamarine ]: GBM: Allocated a new buffer with size [Vector2D: x: 2560, y: 1600] and format XR24 with modifier 0 aka LINEAR
DEBUG from aquamarine ]: Swapchain: Reconfigured a swapchain to [Vector2D: x: 2560, y: 1600] XR24 of length 3
DEBUG from aquamarine ]: drm: Modesetting eDP-1 with 2560x1600@60.00Hz
ERR from aquamarine ]: drm: Cannot commit when a page-flip is awaiting

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions