Skip to content

Fix uninitialized member variable in MetalState#2884

Merged
jstone-lucasfilm merged 1 commit intoAcademySoftwareFoundation:mainfrom
metal-by-example:fix_ubsan_1518
May 6, 2026
Merged

Fix uninitialized member variable in MetalState#2884
jstone-lucasfilm merged 1 commit intoAcademySoftwareFoundation:mainfrom
metal-by-example:fix_ubsan_1518

Conversation

@warrenm
Copy link
Copy Markdown
Contributor

@warrenm warrenm commented May 5, 2026

This PR seeks to address issue #1518.

I believe the first part of this issue to be obsolete. The CMake targets have changed substantially since the issue was reported, and I was able to build with Xcode 12.4 on macOS Catalina 10.15.8 without errors.

The second part of the issue is still relevant. When compiled on a system with a macOS 11+ SDK but running on an OS version prior to macOS 11, the supportsTiledPipeline member variable is not initialized by the constructor or the initialize() method, and can hold an invalid value. This doesn't cause a crash because of further runtime checks in initLinearToSRGBKernel(), but it does raise a runtime issue when compiled with UBSAN.

These changes ensure that the supportsTiledPipeline variable is always initialized, regardless of SDK version or OS version.

Tested on macOS Catalina 10.15.8 with Xcode 12.4 and macOS Tahoe 26.4.1 with Xcode 26.4.1.

@warrenm warrenm changed the title Fixed uninitialized member variable in MetalState Fix uninitialized member variable in MetalState May 5, 2026
@warrenm warrenm marked this pull request as ready for review May 6, 2026 19:08
Copy link
Copy Markdown
Member

@jstone-lucasfilm jstone-lucasfilm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a correct fix to me, and the missing initializer in some MacOS environments was a valid bug. Thanks @warrenm!

@jstone-lucasfilm jstone-lucasfilm merged commit 3811688 into AcademySoftwareFoundation:main May 6, 2026
36 checks passed
@warrenm warrenm deleted the fix_ubsan_1518 branch May 6, 2026 22:44
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.

2 participants