Commit 37440eec authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

Fix fdsan crash on Android

The crash is because fd ownership is passed to vulkan, however the fd
is still hold in base::ScopedFD. It confuses android fdsan, and then
fdsan reports an ownership problem and crashes.

Bug: 1140950
Change-Id: I0cc22992cedb22a649c61e84020317261255e04a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2503008Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821286}
parent 866e9f8f
...@@ -37,24 +37,23 @@ VkSemaphore ImportVkSemaphoreHandle(VkDevice vk_device, ...@@ -37,24 +37,23 @@ VkSemaphore ImportVkSemaphoreHandle(VkDevice vk_device,
base::ScopedFD fd = handle.TakeHandle(); base::ScopedFD fd = handle.TakeHandle();
const auto is_sync_fd = const auto is_sync_fd =
handle_type == VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; handle_type == VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
VkImportSemaphoreFdInfoKHR import = { const VkImportSemaphoreFdInfoKHR import = {
.sType = VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR, .sType = VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR,
.semaphore = semaphore, .semaphore = semaphore,
.flags = is_sync_fd ? VK_SEMAPHORE_IMPORT_TEMPORARY_BIT_KHR : 0, .flags = is_sync_fd ? VK_SEMAPHORE_IMPORT_TEMPORARY_BIT_KHR : 0,
.handleType = handle_type, .handleType = handle_type,
.fd = fd.get(), .fd = fd.release(),
}; };
result = vkImportSemaphoreFdKHR(vk_device, &import); result = vkImportSemaphoreFdKHR(vk_device, &import);
if (result != VK_SUCCESS) { if (result != VK_SUCCESS) {
DLOG(ERROR) << "vkImportSemaphoreFdKHR failed: " << result; DLOG(ERROR) << "vkImportSemaphoreFdKHR failed: " << result;
vkDestroySemaphore(vk_device, semaphore, nullptr); vkDestroySemaphore(vk_device, semaphore, nullptr);
// If import failed, we need to close fd manually.
base::ScopedFD close_fd(import.fd);
return VK_NULL_HANDLE; return VK_NULL_HANDLE;
} }
// If import is successful, the VkSemaphore takes the ownership of the fd.
ignore_result(fd.release());
return semaphore; return semaphore;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment