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

libMali: vkSurfaceKHR SIGSEGV invalid access to (nil) #1637

Closed
samyeda opened this issue Jan 17, 2025 · 3 comments · Fixed by #1639
Closed

libMali: vkSurfaceKHR SIGSEGV invalid access to (nil) #1637

samyeda opened this issue Jan 17, 2025 · 3 comments · Fixed by #1639
Labels
bug Something isn't working

Comments

@samyeda
Copy link

samyeda commented Jan 17, 2025

Describe the bug
Seg Fault at terminator_GetPhysicalDeviceSurfaceFormatsKHR() when using libMali with applications.

Environment (please complete the following information):

  • OS: Linux
  • Bitdepth: 64-bit
  • GPU: Mali-G52
  • Graphics Driver: libMali (-r44p0, -r37p0)
  • SDK or header version if building from repo: 1.3.297
  • Enabled layers: WSI

To Reproduce
Steps to reproduce the behavior:

  1. Execute application

VK_LOADER_DEBUG output
DEBUG | DRIVER: Copying old device 0 into new device 0
INFO: terminator_CreateDisplayPlaneSurfaceKHR
INFO | LAYER: Inserted device layer "VK_LAYER_window_system_integration" (/etc/vulkan/implicit_layer.d/./libVkLayer_window_system_integration.so)
DRIVER | LAYER: vkCreateDevice layer callstack setup to:
DRIVER | LAYER:
DRIVER | LAYER: ||
DRIVER | LAYER:
DRIVER | LAYER: ||
LAYER: VK_LAYER_window_system_integration
LAYER: Type: Implicit
LAYER: Disable Env Var: DISABLE_WSI_LAYER
LAYER: Manifest: /etc/vulkan/implicit_layer.d/VkLayer_window_system_integration.json
LAYER: Library: /etc/vulkan/implicit_layer.d/./libVkLayer_window_system_integration.so
LAYER: ||
DRIVER | LAYER:
DRIVER | LAYER: Using "Mali-G52" with driver: "/usr/lib/libMali.so"
INFO: terminator_GetPhysicalDeviceSurfaceFormatsKHR:
00:00:083 linux/common.cpp:70 E[COMMON]: SIGSEGV @ 0x7faaff54e4 invalid access to (nil)

Additional context
This is caused due to commit 55bd9d6 . After reverting the commit 55bd9d6 the crash doesn't occur.
This maybe be because the mali driver is still expecting vkSurfaceKHR format prior to the commit. The commit is passing invalid vkSurfaceKHR format to the driver.

@samyeda samyeda added the bug Something isn't working label Jan 17, 2025
samyeda added a commit to samyeda/batocera.linux that referenced this issue Jan 17, 2025
Vulkan loader versions since 1.3.296 has introduced a change that is
crashing libMali. Revert the change introduced in vulkan loader

The issue is tracked here
KhronosGroup/Vulkan-Loader#1637
@charles-lunarg
Copy link
Collaborator

The way the Vulkan-Loader wraps VkSurfaceKHR handles means that when a surface is created by the driver, the loader must always unwrap it before calling down into the driver, because otherwise the handle being passed in is the loaders handle, not the drivers.

I'm curious how commit 55bd9d6 was able to break libmali, because it merely removed struct members that were defined by a Vulkan-Loader internal header file wsi.h. Is libMali.so or libVkLayer_window_system_integration.so expecting the Vulkan-Loader VkSurfaceKHR handle, and manually dereferencing it?

@charles-lunarg
Copy link
Collaborator

https://github.com/KhronosGroup/Vulkan-Headers/blob/a03d2f6d5753b365d704d58161825890baad0755/include/vulkan/vk_icd.h#L100

Ah, I think the confusion comes from here.

The Vulkan-Loader had its own definition of the VkSurfaceKHR struct contents, which is VERY misleading. If the definition is actually coming from vk_icd.h, then that is what the loader should be using.

@charles-lunarg charles-lunarg linked a pull request Jan 17, 2025 that will close this issue
@charles-lunarg
Copy link
Collaborator

Yeah, it seems I ignored the vk_icd.h because nothing in the Vulkan-Loader codebase used the VkIcdSurface parameters and therefor concluded that they were unused. From the lack of issues being created, libMali may be the only driver still using the older (ICD interface version 2 and below) method for handling surfaces, which explains why it took a while to surface. Apologies for the inconvenience and breakages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants