Skip to content

Setting interpreter before rpath results in broken binary #674

Open

Description

@rezahousseini

Describe the bug

When running --set-interpreter followed by --set-rpath results in a broken binary. When reversing the order the binary runs fine.

patchelf --version output

0.18

Additional context

This was observed with nvidia-smi in nonguix but not tested with other binaries.

Activity

  1. TPi-Home commented on Oct 20, 2026

    @TPi-Home

    I can reproduce this on both my desktop and laptop running NixOS with patchelf 0.19.2 and the NixOS-packaged NVIDIA driver.

    I also narrowed the failure down to how the interpreter and RPATH are patched:

    Applying --set-interpreter and --set-rpath in a single patchelf invocation produces an executable that segfaults.

    Applying the same changes in separate invocations, with --set-rpath first and --set-interpreter second, works.

    Applying either change individually also works.

    On my desktop, this affects nvidia-smi from NVIDIA driver 595.104.02 on an RTX 3080. The original, unpatched executable works, while the Nix-packaged binary segfaults, including when invoked through the Nix dynamic loader explicitly.

    I also reproduced the issue on my laptop after updating to the latest available NVIDIA driver. This makes a driver-version-specific explanation less likely and points toward the ELF rewriting performed by patchelf, as you have indicated.

    ❯ patchelf --version
    patchelf 0.19.2

  2. DanielTallon commented on Oct 20, 2026

    @DanielTallon

    I also hit this on NixOS (patchelf 0.19.2, nvidia-smi from driver 615.78.08), reported downstream in NixOS/nixpkgs#576412.

    In the broken binary the new read-only LOAD segment overlaps the RW one, so .dynamic ends up mapped read-only and ld.so crashes with SEGV_ACCERR in dl_main. Running --set-rpath and --interpreter as separate calls avoids it, same as described above.

    (Investigated with help from Claude Code.)

  3. b1tflyyyy commented on Oct 20, 2026

    @b1tflyyyy

    the same with nvidia-powerd service, reported here NixOS/nixpkgs#576435

  4. TPi-Home commented on Oct 20, 2026

    @TPi-Home

    I've opened Nixpkgs PR #576397 to apply this workaround.

    I haven't isolated the underlying cause, but I wanted to link the reports in case this is useful for investigating the issue.

  5. TPi-Home commented on Oct 20, 2026

    @TPi-Home

    Looks like they got it fixed upstream. I tested nvidia-smi with both the current Nixpkgs Patchelf and a local build of the latest upstream version. The current version segfaults, but the upstream build works. Just need to wait for the fix to make it into Nixpkgs.

  6. prusnak commented on Oct 23, 2026

    @prusnak
    Member

    gcc-arm-embedded workaround merged in NixOS/nixpkgs#577189

  7. added a commit that references this issue on Oct 25, 2026
  8. 3 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions