#1117930 mesa-opencl-icd: Rusticl ICD dispatch table not initialized - NULL clGetPlatformInfo causes segfault

Package:
mesa-opencl-icd
Source:
mesa-opencl-icd
Description:
free implementation of the OpenCL API -- ICD runtime
Submitter:
Michel Le Bihan
Date:
2025-10-13 17:41:03 UTC
Severity:
normal
#1117930#5
Date:
2025-10-12 16:54:18 UTC
From:
To:
The Rusticl OpenCL ICD causes segfaults in all OpenCL applications when
attempting to query platform information. The crash occurs at address
0x0000000000000000 when calling clGetPlatformInfo on the Rusticl platform.

Reproduction Case 1 - clinfo:
$ clinfo
Found 2 platforms
Platform 0: Portable Computing Language (POCL)
Segmentation fault

GDB session:
(gdb) run
Thread 1 "clinfo" received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()

(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x000055555555e90b in platform_info_str at src/clinfo.c:948
#2  0x0000555555564fa0 in gatherPlatformInfo at src/clinfo.c:1216
#3  0x000055555555d79d in main at src/clinfo.c:4835

(gdb) frame 1
(gdb) print loc->plat
$1 = (cl_platform_id) 0x7ffff79e2950 <rusticl::core::platform::PLATFORM>


Reproduction Case 2 - Minimal test program:
$ cat test_rusticl.c
#include <CL/cl.h>
#include <stdio.h>

int main() {
    cl_platform_id platforms[10];
    cl_uint num_platforms;

    clGetPlatformIDs(10, platforms, &num_platforms);
    printf("Found %d platforms\n", num_platforms);

    for (int i = 0; i < num_platforms; i++) {
        char name[256];
        cl_int err = clGetPlatformInfo(platforms[i], CL_PLATFORM_NAME,
                                       sizeof(name), name, NULL);
        printf("Platform %d: err=%d, name=%s\n", i, err,
               err == CL_SUCCESS ? name : "FAILED");
    }
    return 0;
}

$ gcc test_rusticl.c -lOpenCL -o test_rusticl
$ ./test_rusticl
Found 2 platforms
Platform 0: err=0, name=Portable Computing Language
Segmentation fault

GDB session:
(gdb) run
Thread 1 "test_rusticl" received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()

(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00005555555551c7 in main ()


Additional debugging information:

Platform object memory at 0x7ffff79e2950:
(gdb) x/20xg 0x7ffff79e2950
0x7ffff79e2950: 0x00007ffff79bbe40  0x00005555556a2840
0x7ffff79e2960: 0x0000000000000000  0x0000000000000008
0x7ffff79e2970: 0x0000000000000000  0x000000000000000a
0x7ffff79e2980: 0x0000555555693090  0x000000000000000a
0x7ffff79e2990: 0x0000000000000004  0x00005555556a0d60
0x7ffff79e29a0: 0x0000000000000001  0x8000000000000000

Library symbol check:
$ nm -D /usr/lib/x86_64-linux-gnu/libRusticlOpenCL.so.1.0.0 | grep clGetPlatformInfo
00000000002077c0 T clGetPlatformInfo

$ readelf -s /usr/lib/x86_64-linux-gnu/libRusticlOpenCL.so.1.0.0 | grep clGetPlatformInfo
   961: 00000000002077c0     8 FUNC    GLOBAL DEFAULT   12 clGetPlatformInfo