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

MangoHud Causing synchronization read-after-write validation error and segfault on exit #1214

Open
Tacodiva opened this issue Jan 26, 2024 · 1 comment

Comments

@Tacodiva
Copy link

Tacodiva commented Jan 26, 2024

Describe the bug
When I try to use MangoHud with my game engine, it causes a validation warning and error message every frame:

[Warn][Vk][Validation] Validation Warning: [ UNASSIGNED-BestPractices-ImageBarrierAccessLayout ] | MessageID = 0x849fcec7 | vkCmdPipelineBarrier(): pImageMemoryBarriers[0] image is VkImage 0x564fdd0000000069[] and accessMask is VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT, but for layout VK_IMAGE_LAYOUT_PRESENT_SRC_KHR expected accessMask are VkAccessFlags2(0).
   at Vulkan.VulkanDeviceCommands.vkQueuePresentKHR(VkQueue queue, VkPresentInfoKHR* pPresentInfo)
   [ rest of stack trace...]

[Err][Vk][Validation] Validation Error: [ SYNC-HAZARD-READ-AFTER-WRITE ] Object 0: handle = 0x4256c1000000005d, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0xe4d96472 | vkCmdBeginRenderPass: Hazard READ_AFTER_WRITE in subpass 0 for attachment 0 aspect color during load with loadOp VK_ATTACHMENT_LOAD_OP_LOAD. Access info (usage: SYNC_COLOR_ATTACHMENT_OUTPUT_COLOR_ATTACHMENT_READ, prior_usage: SYNC_IMAGE_LAYOUT_TRANSITION, write_barriers: SYNC_COLOR_ATTACHMENT_OUTPUT_COLOR_ATTACHMENT_WRITE, command: vkCmdPipelineBarrier, seq_no: 4, reset_no: 2).
   at Vulkan.VulkanDeviceCommands.vkQueuePresentKHR(VkQueue queue, VkPresentInfoKHR* pPresentInfo)
   [ rest of stack trace...]

It still seems to work fine on my drivers despite the validation error. When I close the window in my engine, I get a segfault only when using mangohud. GDB reported the following (probably not very helpful) stacktrace:

#0  0x00007ffff7a72051 in __GI__IO_getline_info (fp=fp@entry=0x7fbdec000b70, 
    buf=buf@entry=0x7fbe804bd2a0 <error: Cannot access memory at address 0x7fbe804bd2a0>, n=1022, n@entry=1023, 
    delim=delim@entry=10, extract_delim=extract_delim@entry=1, eof=eof@entry=0x0) at iogetline.c:77
#1  0x00007ffff7a7213c in __GI__IO_getline (fp=fp@entry=0x7fbdec000b70, 
    buf=buf@entry=0x7fbe804bd2a0 <error: Cannot access memory at address 0x7fbe804bd2a0>, n=n@entry=1023, 
    delim=delim@entry=10, extract_delim=extract_delim@entry=1) at iogetline.c:34
#2  0x00007ffff7a70de0 in _IO_fgets (buf=0x7fbe804bd2a0 <error: Cannot access memory at address 0x7fbe804bd2a0>, n=1024, 
    fp=0x7fbdec000b70) at iofgets.c:53
#3  0x00007fbe8029060a in ?? ()
#4  0x0000000000000000 in ?? ()

I was not able to determine what Vulkan command was causing the segfault, but it happens when I close the window and the engine tries to exit so probably one of the vkDestroy... commands. I'm also not sure if the segfault is happening in the driver due to incorrect usage of the API or if it's MangoHud itself.

List relevant hardware/software information

  • EndeavourOS Kernel 6.6.9-arch1
  • MangoHud AUR Package 0.7.0-2
  • GPU Intel TigerLake-H GT1 [UHD Graphics]
  • Vulkan Validation Layers / SDK 1.3.268.0

To Reproduce

I assume this is something strange I'm doing within my engine, but I'm not sure what that could be. Without MangoHud, it works fine without validation issues. I would prefer not to release my engine at this time, though I'm happy to answer any questions if need be.

@Tacodiva Tacodiva changed the title MangoHud Causing synchronization read-after-write validation error MangoHud Causing synchronization read-after-write validation error and segfault on exit Jan 27, 2024
@sudoBash418
Copy link

I'm seeing the same behaviour using Bevy - even minimal examples result in SYNC-HAZARD-READ-AFTER-WRITE validation errors when MangoHud is enabled.

$ git checkout v0.15.0  # using Bevy 0.15
$ MANGOHUD=1 cargo run --example 2d_shapes
[...]
2025-01-03T21:45:22.179605Z  INFO bevy_render::renderer: AdapterInfo { name: "AMD Radeon RX 7600 (RADV NAVI33)", vendor: 4098, device: 29824, device_type: DiscreteGpu, driver: "radv", driver_info: "Mesa 25.0.0-devel (git-30d9166d80)", backend: Vulkan }
[...]
2025-01-03T21:45:30.142219Z ERROR present_frames: wgpu_hal::vulkan::instance: 	objects: (type: RENDER_PASS, hndl: 0x7675b400000000eb, name: ?)    
2025-01-03T21:45:30.159109Z ERROR present_frames: wgpu_hal::vulkan::instance: VALIDATION [SYNC-HAZARD-READ-AFTER-WRITE (0xe4d96472)]
	Validation Error: [ SYNC-HAZARD-READ-AFTER-WRITE ] Object 0: handle = 0x7675b400000000eb, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0xe4d96472 | vkCmdBeginRenderPass():  Hazard READ_AFTER_WRITE in subpass 0 for attachment 0 aspect color during load with loadOp VK_ATTACHMENT_LOAD_OP_LOAD. Access info (usage: SYNC_COLOR_ATTACHMENT_OUTPUT_COLOR_ATTACHMENT_READ, prior_usage: SYNC_IMAGE_LAYOUT_TRANSITION, write_barriers: SYNC_COLOR_ATTACHMENT_OUTPUT_COLOR_ATTACHMENT_WRITE, command: vkCmdPipelineBarrier, seq_no: 1, reset_no: 556).    
2025-01-03T21:45:30.159155Z ERROR present_frames: wgpu_hal::vulkan::instance: 	objects: (type: RENDER_PASS, hndl: 0x7675b400000000eb, name: ?)    
2025-01-03T21:45:30.175621Z ERROR present_frames: wgpu_hal::vulkan::instance: VALIDATION [SYNC-HAZARD-READ-AFTER-WRITE (0xe4d96472)]
	Validation Error: [ SYNC-HAZARD-READ-AFTER-WRITE ] Object 0: handle = 0x7675b400000000eb, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0xe4d96472 | vkCmdBeginRenderPass():  Hazard READ_AFTER_WRITE in subpass 0 for attachment 0 aspect color during load with loadOp VK_ATTACHMENT_LOAD_OP_LOAD. Access info (usage: SYNC_COLOR_ATTACHMENT_OUTPUT_COLOR_ATTACHMENT_READ, prior_usage: SYNC_IMAGE_LAYOUT_TRANSITION, write_barriers: SYNC_COLOR_ATTACHMENT_OUTPUT_COLOR_ATTACHMENT_WRITE, command: vkCmdPipelineBarrier, seq_no: 1, reset_no: 558).

Disabling the overlay with a keybind stops the error spam.
Sometimes user-initiated exits (via ctrl-c or closing the window) result in segfaults, other times not.

GPU: AMD Radeon RX 7600
System info:

$ pacman -Q mesa-tkg-git mangohud vulkan-validation-layers
mesa-tkg-git 25.0.0_devel.197487.30d9166d803-1
mangohud 0.7.2-2
vulkan-validation-layers 1.3.296.0-1

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

No branches or pull requests

2 participants