[Pkg-opencl-devel] Bug#1117985: opencl-clhpp-headers: clGetExtensionFunctionAddressForPlatform used without checking API version

Bob Ham rah+debianbts at settrans.net
Mon Oct 13 10:51:22 BST 2025


Package: opencl-clhpp-headers
Version: 3.0~2024.10.24-2
Severity: important

Almost everywhere in opencl.hpp, calls to
clGetExtensionFunctionAddressForPlatform, via
CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_, are within #ifdef's to check the
API version, for example:

  #if CL_HPP_TARGET_OPENCL_VERSION >= 120
          CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(object_, clGetDeviceIDsFromD3D10KHR);
  #endif
  #if CL_HPP_MINIMUM_OPENCL_VERSION < 120
          CL_HPP_INIT_CL_EXT_FCN_PTR_(clGetDeviceIDsFromD3D10KHR);
  #endif

except in initMemoryExtension where there is no guard:

    static void initMemoryExtension(const cl::Device& device) 
    {
        auto platform = device.getInfo<CL_DEVICE_PLATFORM>()();

        CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireExternalMemObjectsKHR);
        CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseExternalMemObjectsKHR);

Because clGetExtensionFunctionAddressForPlatform is specific to CL 1.2
and greater, this lack of #ifdef's causes errors when limiting the API
to CL 1.1.  For example:

  #define CL_TARGET_OPENCL_VERSION 110
  #define CL_HPP_MINIMUM_OPENCL_VERSION 110
  #define CL_HPP_TARGET_OPENCL_VERSION 110
  
  #include <CL/opencl.hpp>
  
  int main()
  {
    return 0;
  }

causes:

  g++     test-case.cpp   -o test-case
  In file included from test-case.cpp:5:
  /usr/include/CL/opencl.hpp: In static member function ‘static void cl::CommandQueue::initMemoryExtension(const cl::Device&)’:
  /usr/include/CL/opencl.hpp:7600:9: error: ‘clGetExtensionFunctionAddressForPlatform’ was not declared in this scope; did you mean ‘clGetExtensionFunctionAddress’?
   7600 |         CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueAcquireExternalMemObjectsKHR);
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /usr/include/CL/opencl.hpp:7601:9: error: ‘clGetExtensionFunctionAddressForPlatform’ was not declared in this scope; did you mean ‘clGetExtensionFunctionAddress’?
   7601 |         CL_HPP_INIT_CL_EXT_FCN_PTR_PLATFORM_(platform, clEnqueueReleaseExternalMemObjectsKHR);
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  make: *** [<builtin>: test-case] Error 1



-- System Information:
Debian Release: 13.1
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.12.48+deb13-amd64 (SMP w/16 CPU threads; PREEMPT)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: sysvinit (via /sbin/init)
LSM: AppArmor: enabled

Versions of packages opencl-clhpp-headers depends on:
ii  opencl-c-headers  3.0~2024.10.24-2

opencl-clhpp-headers recommends no packages.

Versions of packages opencl-clhpp-headers suggests:
pn  opencl-clhpp-headers-doc  <none>

-- no debconf information


More information about the Pkg-opencl-devel mailing list