Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UBSAN testing #9384

Open
jpr42 opened this issue Feb 3, 2025 · 3 comments
Open

Add UBSAN testing #9384

jpr42 opened this issue Feb 3, 2025 · 3 comments
Assignees
Labels
Build Issues with the build CI/Tests Anything related to CI or testing

Comments

@jpr42
Copy link
Contributor

jpr42 commented Feb 3, 2025

Similar to the existing address sanitization and thread sanitization it's worth adding undefined behavior sanitization testing:
https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html

Running VVL tests with UBSAN does show failing tests.

Here is an example:

[ RUN      ] NegativeCommand.MultiDraw
/home/juaramos/projects/Vulkan-ValidationLayers/layers/core_checks/cc_drawdispatch.cpp:284:96: runtime error: member access within misaligned address 0x7ffdc5bf777d for type 'const struct VkMultiDrawIndexedInfoEXT', which requires 4 byte alignment
0x7ffdc5bf777d: note: pointer points here
 00 00 00 00 00 00 00  01 00 00 00 00 00 00 00  00 00 00 00 01 00 00 00  00 00 00 00 00 00 00 00  00
             ^ 
Command "/home/juaramos/projects/Vulkan-ValidationLayers/build-ci/install/bin/vk_layer_validation_tests" failed with return code -6

NOTE: This doesn't need to be a new CI pass. This can just be added to ASAN testing.

GCC / Clang accept the following: -fsanitize=address,undefined.

NOTE: I had to set the environment variable UBSAN_OPTIONS to abort_on_error=1:halt_on_error=1 to get lldb to quickly point me to the exact problem when running the tests in vscode.

EDIT: For further reference glslang implemented it in this PR KhronosGroup/glslang#3654

@spencer-lunarg spencer-lunarg added the CI/Tests Anything related to CI or testing label Feb 4, 2025
@spencer-lunarg spencer-lunarg self-assigned this Feb 4, 2025
@spencer-lunarg spencer-lunarg added the Build Issues with the build label Feb 6, 2025
@spencer-lunarg
Copy link
Contributor

Did a quick attempt in a branch (https://github.com/spencer-lunarg/Vulkan-ValidationLayers/actions/runs/13181233782/job/36792380702)

Getting strange linking errors

/usr/bin/ld: source/opt/libSPIRV-Tools-opt.a(pass_manager.cpp.o):(.data.rel+0x58): undefined reference to typeinfo for spvtools::utils::Timer'`

I had similar in Glslang (which I see you caught) but seems we might have to fix SPIRV-Tools as well first

@jpr42
Copy link
Contributor Author

jpr42 commented Feb 6, 2025

Getting strange linking errors

It's related to RTTI from what I could tell:
https://stackoverflow.com/questions/37358573/why-does-fsanitize-undefined-cause-undefined-reference-to-typeinfo

SPIRV-Tools disables it by default.

@jpr42
Copy link
Contributor Author

jpr42 commented Feb 6, 2025

Also I looked at your branch. You will want to set the environment variable UBSAN_OPTION when running the tests.

glslang for reference:
https://github.com/KhronosGroup/glslang/blob/39766a06679bf5e4bc1e0339136f1b6a519fcec5/.github/workflows/continuous_integration.yml#L119

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Issues with the build CI/Tests Anything related to CI or testing
Projects
None yet
Development

No branches or pull requests

2 participants