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

Allow tests to directly call loader internal functions & Always memset newly reallocated memory #1629

Merged

Conversation

charles-lunarg
Copy link
Collaborator

  • Rename loader_platform_* to test_platform_*

This prevents conflicts with the loaders and tests platform abstractions.

  • Use GoogleTest as static library

There is no advantage to dynamically linking googletest into the loader test framework. Removing it also removes some CMake code that copies the gtest.dll, which is a nice benefit.

  • Allow tests to directly call loader internal functions

This allows the fuzz tests to faithfully recreate the calling environment
of OSS-Fuzz, meaning reproduction of failing fuzz tests can be done in the
repo for regression testing.

The implementation of this requires exporting several functions that the
fuzz tests need which is done with a new macro that is only active when
a specific compiler definition is set, which the build does when testing
is active.

  • Always memset newly reallocated memory

Fuzz testing found a case where memory was left uninitialized after
calling loader_realloc, causing a crash due to reading of that memory.
The fix is to always memset newly reallocated memory, since a value of
zero is a good default value, especially if that memory is for a list.
This commit removes the redundant memsets, since realloc now has the
responsibility to initialize memory.

  • Include fuzz test which needs realloc memsetting

Test case for the previous commit that was discovered later - more test cases is rarely a bad thing.

This prevents conflicts with the loaders and tests platform abstractions.
This allows the fuzz tests to faithfully recreate the calling environment
of OSS-Fuzz, meaning reproduction of failing fuzz tests can be done in the
repo for regression testing.

The implementation of this requires exporting several functions that the
fuzz tests need which is done with a new macro that is only active when
a specific compiler definition is set, which the build does when testing
is active.
Fuzz testing found a case where memory was left uninitialized after
calling loader_realloc, causing a crash due to reading of that memory.
The fix is to *always* memset newly reallocated memory, since a value of
zero is a good default value, especially if that memory is for a list.
This commit removes the redundant memsets, since realloc now has the
responsibility to initialize memory.
@ci-tester-lunarg
Copy link

CI Vulkan-Loader build queued with queue ID 338536.

@ci-tester-lunarg
Copy link

CI Vulkan-Loader build queued with queue ID 338553.

@ci-tester-lunarg
Copy link

CI Vulkan-Loader build # 2844 running.

@ci-tester-lunarg
Copy link

CI Vulkan-Loader build # 2844 passed.

@charles-lunarg charles-lunarg merged commit 369f59a into KhronosGroup:main Jan 6, 2025
44 checks passed
@charles-lunarg charles-lunarg deleted the fuzz_testing_improvements branch January 6, 2025 21:04
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