Skip to content

Commit

Permalink
Check correct magic value in device dispatch table
Browse files Browse the repository at this point in the history
The check for a correct magic value in the device dispatch table used
LOADER_MAGIC_NUMBER instead of DEVICE_DISP_TABLE_MAGIC_NUMBER. This causes
every device creation to emit the 'invalid magic value' message, which is
wrong. This commit fixes that, as well as adds the expected value to the
log message.
  • Loading branch information
charles-lunarg committed Sep 15, 2023
1 parent d40385b commit 45b155b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions loader/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -5597,9 +5597,10 @@ VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDevice(VkPhysicalDevice physical
loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0,
"terminator_CreateDevice: Loader device pointer null encountered. Possibly set by active layer. (Policy "
"#LLP_LAYER_22)");
} else if (LOADER_MAGIC_NUMBER != dev->loader_dispatch.core_dispatch.magic) {
} else if (DEVICE_DISP_TABLE_MAGIC_NUMBER != dev->loader_dispatch.core_dispatch.magic) {
loader_log(icd_term->this_instance, VULKAN_LOADER_WARN_BIT, 0,
"terminator_CreateDevice: Device pointer (%p) has invalid MAGIC value 0x%08x. Device value possibly "
"terminator_CreateDevice: Device pointer (%p) has invalid MAGIC value 0x%08lx. The expected value is "
"0x10ADED040410ADED. Device value possibly "
"corrupted by active layer (Policy #LLP_LAYER_22). ",
dev, dev->loader_dispatch.core_dispatch.magic);
}
Expand Down
13 changes: 7 additions & 6 deletions tests/loader_regression_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4130,19 +4130,20 @@ TEST(Layer, LLP_LAYER_22) {
ASSERT_DEATH(
dev.CheckCreate(inst.GetPhysDev()),
testing::ContainsRegex(
R"(terminator_CreateDevice: Device pointer \(................\) has invalid MAGIC value 0x00000000. Device value )"
R"(terminator_CreateDevice: Device pointer \(................\) has invalid MAGIC value 0x00000000. The expected value is 0x10ADED040410ADED. Device value )"
R"(possibly corrupted by active layer \(Policy #LLP_LAYER_22\))"));
#else
ASSERT_DEATH(dev.CheckCreate(inst.GetPhysDev()),
testing::ContainsRegex(
R"(terminator_CreateDevice: Device pointer \(........\) has invalid MAGIC value 0x00000000. Device value )"
R"(possibly corrupted by active layer \(Policy #LLP_LAYER_22\))"));
ASSERT_DEATH(
dev.CheckCreate(inst.GetPhysDev()),
testing::ContainsRegex(
R"(terminator_CreateDevice: Device pointer \(........\) has invalid MAGIC value 0x00000000. The expected value is 0x10ADED040410ADED. Device value )"
R"(possibly corrupted by active layer \(Policy #LLP_LAYER_22\))"));
#endif
#else
ASSERT_DEATH(
dev.CheckCreate(inst.GetPhysDev()),
testing::ContainsRegex(
R"(terminator_CreateDevice: Device pointer \(0x[0-9A-Fa-f]+\) has invalid MAGIC value 0x00000000. Device value )"
R"(terminator_CreateDevice: Device pointer \(0x[0-9A-Fa-f]+\) has invalid MAGIC value 0x00000000. The expected value is 0x10ADED040410ADED. Device value )"
R"(possibly corrupted by active layer \(Policy #LLP_LAYER_22\))"));
#endif
}

0 comments on commit 45b155b

Please sign in to comment.