Distro News

Missing NDEBUG build flag caused btop to crash on Fedora with AMD GPUs

Key Takeaway

A packaging error in Fedora's rocm-smi library caused terminal resource monitors to abort due to unhandled assertions when parsing specific AMD sysfs data.

Summary

A technical investigation has revealed why the btop resource monitor was crashing on Fedora systems equipped with AMD GPUs. The issue stemmed from the rocm-smi library, which is used to expose data from the amdgpu driver to userspace applications.

The crash occurred because the Fedora package for rocm-smi failed to define the NDEBUG build flag. This caused development-level assertions to remain active in the production binary, leading to immediate program aborts when the library encountered specific hardware frequency formats common on AMD APUs.

The technical chain of the rocm-smi crash

  • Kernel sysfs interaction: The amdgpu driver prints hardware frequency data to /sys/class/drm/card0/device/pp_dpm_mclk. On certain AMD APUs, the kernel outputs an extra line without an index when the current frequency does not match a predefined level.
  • Parser failure: The rocm-smi library's get_multiplier_from_str function fails to parse this unindexed line, resulting in an empty unit string and a null character input.
  • Assertion trigger: Because the Fedora build did not define the NDEBUG macro, the code executed an 'assert(false)' statement instead of throwing a catchable exception, causing the entire process to terminate via abort().
  • Packaging error: Fedora's %cmake macro defines release flags but does not set CMAKE_BUILD_TYPE; without this type being set to 'Release', the -DNDEBUG flag was never actually applied during the build process.

Why it matters

This incident highlights the critical importance of correct build-type configuration in Linux distribution packaging. It demonstrates how a mismatch between upstream development assumptions and downstream packaging logic can turn a recoverable software exception into a fatal system crash.

Original reference: fedoramagazine.org →