Skip to content

Segfault in rocsparse_create_handle with Ubuntu-packaged ROCm 7.1 (Ubuntu 26.04) #987

Description

@luraess

Split out from #920. The discovery half of that issue is fixed and merged in #934; what remains is an unrelated crash, tracked here.

Summary

On Ubuntu 26.04 with ROCm installed from the Ubuntu archive (apt install rocm, 7.1.0-0ubuntu6) rather than from repo.radeon.com, creating a rocSPARSE handle segfaults inside libamdhip64.so. HIP itself initialises fine and rocBLAS works, so this looks specific to rocSPARSE's HIP interaction in the distro packaging.

Because AMDGPU.versioninfo() creates a rocSPARSE handle to report its version, the crash takes down the whole Julia session (see "Collateral" below).

Environment

OS Ubuntu 26.04 (resolute)
ROCm rocm / rocm-dev 7.1.0-0ubuntu6 (Ubuntu archive, not repo.radeon.com)
Install prefix /usr/lib/x86_64-linux-gnu (no /opt/rocm)
GPU AMD Radeon RX 7600, gfx1102
Julia 1.12.6
AMDGPU.jl v2.5.1 with #934 applied
HIP lib libamdhip64.solibamdhip64.so.7libamdhip64.so.7.1.52801

What works

Discovery is correct after #934, and HIP is healthy:

julia> println("HIP:      ", AMDGPU.libhip)
HIP:      /usr/lib/x86_64-linux-gnu/libamdhip64.so
julia> println("HSA:      ", AMDGPU.libhsaruntime)
HSA:      /usr/lib/x86_64-linux-gnu/libhsa-runtime64.so.1
julia> println("rocsparse:", AMDGPU.librocsparse)
rocsparse:/usr/lib/x86_64-linux-gnu/librocsparse.so

julia> AMDGPU.HIP.devices()
┌────┬────────────────────┬──────────┬───────────┬───────────┬───────────────┐
│ Id │               Name │ GCN arch │ Wavefront │    Memory │ Shared Memory │
├────┼────────────────────┼──────────┼───────────┼───────────┼───────────────┤
│  1 │ AMD Radeon RX 7600 │  gfx1102 │        327.984 GiB │    64.000 KiB │
└────┴────────────────────┴──────────┴───────────┴───────────┴───────────────┘

julia> AMDGPU.rocBLAS.version()
v"5.1.0"

ldd shows no unresolved dependencies; both rocSPARSE and rocBLAS link the same libamdhip64.so.7.

What fails

julia> AMDGPU.versioninfo()
[ Info: AMDGPU versioninfo

[9750] signal 11 (1): Segmentation fault
unknown function (ip: 0x70bbe5274516) at /usr/lib/x86_64-linux-gnu/libamdhip64.so
unknown function (ip: 0x70bbe5529dbf) at /usr/lib/x86_64-linux-gnu/libamdhip64.so
unknown function (ip: 0x70bbe54cbe30) at /usr/lib/x86_64-linux-gnu/libamdhip64.so
unknown function (ip: 0x70bbe54e7ae1) at /usr/lib/x86_64-linux-gnu/libamdhip64.so
unknown function (ip: 0x70bb884cfd2e) at /usr/lib/x86_64-linux-gnu/librocsparse.so
rocsparse_create_handle at /usr/lib/x86_64-linux-gnu/librocsparse.so (unknown line)
macro expansion at src/sparse/error.jl:80 [inlined]
rocsparse_create_handle at src/sparse/librocsparse.jl:7 [inlined]
create_handle at src/sparse/rocSPARSE.jl:31 [inlined]
...
version at src/sparse/rocSPARSE.jl:46
_ver at src/utils.jl:5 [inlined]
versioninfo at src/utils.jl:6

Also reproduces with ENV["ROCM_PATH"] = "/usr" set explicitly, so it is not a
discovery side effect.

Analysis

The crash is four frames deep inside libamdhip64.so, reached from rocsparse_create_handle. hipGetDeviceCount-style calls succeed beforehand (HIP.devices() works), which suggests the problem is in rocSPARSE's own HIP context setup rather than HIP initialisation generally.

Notably rocBLAS.version() succeeds — rocBLAS also creates a handle — so it is not simply "any HIP handle crashes".

Current suspicion is a packaging/ABI mismatch in the Ubuntu-archive ROCm build rather than an AMDGPU.jl bug. This is unconfirmed and the point of the MWE below.

Next step: is it Julia or is it Ubuntu?

The following C++ MWE isolates whether the crash needs Julia's dlopen at all. If it segfaults standalone, this is an upstream Ubuntu packaging bug and should be reported to Ubuntu, not fixed here.

mwe_rocsparse.cpp:

#include <stdio.h>
#include <hip/hip_runtime.h>
#include <rocsparse/rocsparse.h>

int main(int argc, char** argv) {
    bool init_hip_first = (argc > 1);

    if (init_hip_first) {
        printf("Initialising HIP first...\n");
        int count = 0;
        hipError_t hip_status = hipGetDeviceCount(&count);
        printf("hipGetDeviceCount: %d  (devices: %d)\n", hip_status, count);
    }

    printf("Calling rocsparse_create_handle...\n");
    rocsparse_handle handle;
    rocsparse_status status = rocsparse_create_handle(&handle);
    printf("rocsparse_create_handle status: %d\n", status);

    if (status == rocsparse_status_success) {
        printf("Success — destroying handle\n");
        rocsparse_destroy_handle(handle);
    }
    return 0;
}
hipcc -o mwe_rocsparse mwe_rocsparse.cpp -lrocsparse
./mwe_rocsparse        # variant 1: no prior HIP init
./mwe_rocsparse hip    # variant 2: HIP initialised first (mimics AMDGPU.jl)

Anyone on Ubuntu 26.04 with archive-installed ROCm running these two variants would unblock this.

Collateral: versioninfo() should not create handles

Independent of the root cause, AMDGPU.versioninfo() currently creates a rocSPARSE handle in order to print a version string (src/utils.jl:20rocSPARSE.version()handle()create_handle()).

That means the function users are told to run because their setup is broken can die with an uncatchable SIGSEGV in a vendor library, destroying the session and the diagnostic output. This happened twice in #920 and is what made the original report hard to triage.

Worth fixing regardless of the outcome above:

  • print availability and paths by default, gating version queries behind an opt-in kwarg (versioninfo(; versions=true)); or
  • run version probes in a subprocess so a crash degrades to - in the table.

I'd favour the first.

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