Skip to content

[SYCL] Fix ODR violation causing SpecializationConstant test segfaults - #22817

Open
ldorau wants to merge 1 commit into
intel:syclfrom
ldorau:SYCL_Fix_ODR_violation_causing_SpecializationConstant_test_segfaults
Open

[SYCL] Fix ODR violation causing SpecializationConstant test segfaults#22817
ldorau wants to merge 1 commit into
intel:syclfrom
ldorau:SYCL_Fix_ODR_violation_causing_SpecializationConstant_test_segfaults

Conversation

@ldorau

@ldorau ldorau commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

SpecializationConstant.cpp declared its own global class TestKernel
and specialized detail::KernelInfo with
getName()="SpecializationConstant_TestKernel". However,
unittests/helpers/TestKernel.hpp (included by other tests linked into
the same binary, e.g. via TestKernel/KernelID/IsCompatible tests) also
declares a global class TestKernel with a different KernelInfo
specialization (getName()="TestKernel").

This is an ODR violation: two different definitions of the same
template specialization in the same program. The linker silently
picks one definition, so SpecializationConstant.cpp's
get_kernel_id() could resolve to the wrong kernel ID,
causing device_image_impl to look up a mock device image with empty
property sets and segfault when dereferencing the (empty) spec
constant blob.

Fix by renaming the test-local class to SpecConstTestKernel, which no
longer collides with the shared TestKernel class.

It was found in the local build.

@ldorau
ldorau requested a review from a team as a code owner July 30, 2026 10:31
@ldorau

ldorau commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Please review @intel/llvm-reviewers-runtime @KseniyaTikhomirova

@ldorau
ldorau force-pushed the SYCL_Fix_ODR_violation_causing_SpecializationConstant_test_segfaults branch 2 times, most recently from e7a264f to 2f67928 Compare July 30, 2026 10:40
SpecializationConstant.cpp declared its own global class TestKernel
and specialized detail::KernelInfo<TestKernel> with
getName()="SpecializationConstant_TestKernel". However,
unittests/helpers/TestKernel.hpp (included by other tests linked into
the same binary, e.g. via TestKernel/KernelID/IsCompatible tests) also
declares a global class TestKernel with a different KernelInfo<TestKernel>
specialization (getName()="TestKernel").

This is an ODR violation: two different definitions of the same
template specialization in the same program. The linker silently
picks one definition, so SpecializationConstant.cpp's
get_kernel_id<TestKernel>() could resolve to the wrong kernel ID,
causing device_image_impl to look up a mock device image with empty
property sets and segfault when dereferencing the (empty) spec
constant blob.

Fix by renaming the test-local class to SpecConstTestKernel, which no
longer collides with the shared TestKernel class.

It was found in the local build.

Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant