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

Launching with Vulkan driver causes a segfault #165

Closed
RobertTheSable opened this issue Sep 9, 2020 · 18 comments
Closed

Launching with Vulkan driver causes a segfault #165

RobertTheSable opened this issue Sep 9, 2020 · 18 comments

Comments

@RobertTheSable
Copy link

Launching Dolphin build from the current master (f4f4947) with the Vulkan driver enabled and core driver switching disabled results in a segfault.

The driver appears to have been broken by the 5.0 rebase, as the last commit I can verify it worked on was cf6c736.

I'm running on Kubuntu 20.04 with an AMD Radeon RX 480 GPU, using the amdgpu driver. I'm not sure if it's a Linux specific issue or not.

@bslenul
Copy link

bslenul commented Sep 14, 2020

I'm not sure if it's a Linux specific issue or not.

Loads fine with Vulkan + "Allow Cores to Switch the Video Driver" OFF on Windows 10 at least.

@yoyossef
Copy link

yoyossef commented Nov 9, 2020

I also have got the same issue on Manjaro (Arch Linux) with an Intel iGPU using mesa driver.

@mikedebian
Copy link

Same issue cf6ca2a47f

Vega 56, MESA
Arch Linux.

Two other cores I have loaded up, and stand alone dolphin emulator works fine with Vulkan.

Works in GL.

@jason-oliveira
Copy link

jason-oliveira commented Jun 20, 2021

Seems this might be an amdgpu issue. I'm experiencing the same issue here as well. Works fine in GL (but slower), segfaults as soon as launched with vulkan. Standalone dolphin does Vulkan fine as well.

All I get GLX reporting invalid screen size results, and then the app crashes. here's a dump: https://hastebin.com/wuzediwone.sql

@ArthurBorsboom
Copy link

Libretro dolphin also crashes on my system.

  • OS: Arch Linux, kernel 5.12.15
  • GPU: Intel(R) HD Graphics 520 (SKL GT2)
  • Vulkan package: vulkan-intel 21.1.4 (mesa)
  • Vulkan Instance Version: 1.2.182
  • Retroarch: 1.9.6
  • Libretro-dolphin: 32990 (commit: 13ad7dd)

Setting retroarch

  • video_driver = "glcore" > works
  • video_driver = "vulkan" > segfault in retroarch

The vulkan renderer does work for other libretro backends.

Getting a backtrace by gdb gave me no interesting results due to debug symbols missing.
I am not what the best way is to provide more information.

Please instruct me if more information is needed.

@zyoungdev
Copy link

zyoungdev commented Aug 21, 2021

Arch Linux with Intel graphics. OpenGL works fine. I was able to get a backtrace out of libretro-dolphin.so but the segfault happens in the Vulkan library.

$ vulkaninfo
==========
VULKANINFO
==========

Vulkan Instance Version: 1.2.186

Instance Extensions: count = 18
===============================
        VK_EXT_acquire_xlib_display            : extension revision 1
        VK_EXT_debug_report                    : extension revision 9
        VK_EXT_debug_utils                     : extension revision 2
        VK_EXT_direct_mode_display             : extension revision 1
        VK_EXT_display_surface_counter         : extension revision 1
        VK_KHR_device_group_creation           : extension revision 1
        VK_KHR_display                         : extension revision 23
        VK_KHR_external_fence_capabilities     : extension revision 1
        VK_KHR_external_memory_capabilities    : extension revision 1
        VK_KHR_external_semaphore_capabilities : extension revision 1
        VK_KHR_get_display_properties2         : extension revision 1
        VK_KHR_get_physical_device_properties2 : extension revision 2
        VK_KHR_get_surface_capabilities2       : extension revision 1
        VK_KHR_surface                         : extension revision 25
        VK_KHR_surface_protected_capabilities  : extension revision 1
        VK_KHR_wayland_surface                 : extension revision 6
        VK_KHR_xcb_surface                     : extension revision 6
        VK_KHR_xlib_surface                    : extension revision 6

...

segfault happens at ./Source/Core/VideoBackends/Vulkan/VulkanContext.cpp:932 when calling function vkGetPhysicalDeviceProperties2(...)

Here's the backtrace in gdb:

#0  0x0000000000000000 in  ()
#1  0x00007fffb61123e7 in Vulkan::VulkanContext::PopulateShaderSubgroupSupport() (this=0x555556aefca0) at /home/z/dolphin/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp:932
#2  0x00007fffb6110903 in Vulkan::VulkanContext::Create(VkInstance_T*, VkPhysicalDevice_T*, VkSurfaceKHR_T*, bool, bool) (instance=0x55555666ff70, gpu=0x555556356cd0, surface=0x555556557570, enable_debug_reports=false, enable_validation_layer=false) at /home/z/dolphin/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp:412
#3  0x00007fffb5d91b0e in Libretro::Video::Vk::CreateDevice(retro_vulkan_context*, VkInstance, VkPhysicalDevice, VkSurfaceKHR, PFN_vkGetInstanceProcAddr, char const**, unsigned int, char const**, unsigned int, VkPhysicalDeviceFeatures const*) (context=0x7fffffff0ae0, instance=0x55555666ff70, gpu=0x555556356cd0, surface=0x555556557570, get_instance_proc_addr=0x7fffe3745200 <vkGetInstanceProcAddr>, required_device_extensions=0x555556089548, num_required_device_extensions=1, required_device_layers=0x0, num_required_device_layers=0, required_features=0x7fffffff0c40) at /home/z/dolphin/Source/Core/DolphinLibretro/Video.cpp:277
#4  0x00005555558c2a16 in  ()
#5  0x00005555558c65a8 in  ()
#6  0x000055555589f521 in  ()
#7  0x00005555558c0d65 in  ()
#8  0x000055555564fe69 in  ()
#9  0x00005555556565ad in  ()
#10 0x0000555555667877 in  ()
#11 0x0000555555668adb in  ()
#12 0x0000555555841a87 in  ()
#13 0x0000555555640d17 in  ()
#14 0x00005555557f7ebd in  ()
#15 0x0000555555844411 in  ()
#16 0x0000555555640d17 in  ()
#17 0x00005555557f7ebd in  ()
#18 0x00005555557f896d in  ()
#19 0x000055555563ac90 in  ()
#20 0x0000555555640414 in  ()
#21 0x000055555564a9a7 in  ()
#22 0x000055555564bcb9 in  ()
#23 0x000055555564e4f9 in  ()
#24 0x00007ffff3dc9b25 in __libc_start_main () at /usr/lib/libc.so.6
#25 0x000055555561850e in  ()

@65a
Copy link

65a commented Sep 24, 2021

Same issue, Lakka nightly Generic x86. Intel(R) Iris(R) Pro Graphics 580 (SKL GT4). gl and glcore drivers work fine. vulkan dolphin launch crashes with

[libretro INFO] 42:47:978 Common/FileUtil.cpp:205 I[COMMON]: CreateFullPath: path /storage/savefiles/User/Dump/Objects/
[libretro INFO] 42:47:978 Common/FileUtil.cpp:209 I[COMMON]: CreateFullPath: path exists /storage/savefiles/User/Dump/Objects/
[libretro INFO] 42:47:978 Common/FileUtil.cpp:205 I[COMMON]: CreateFullPath: path /storage/savefiles/User/Dump/Textures/
[libretro INFO] 42:47:978 Common/FileUtil.cpp:209 I[COMMON]: CreateFullPath: path exists /storage/savefiles/User/Dump/Textures/
[libretro INFO] 42:47:980 Core/Core.cpp:1049 N[COMMON]: Want determinism <- false
[libretro INFO] 42:47:980 Core/Core.cpp:239 I[BOOT]: Starting core = GameCube mode
[libretro INFO] 42:47:980 Core/Core.cpp:240 I[BOOT]: CPU Thread separate = Yes
[INFO] [Environ]: GET_RUMBLE_INTERFACE.
[libretro INFO] 42:47:395 Common/FileUtil.cpp:269 I[COMMON]: Rename: /storage/savefiles/User/Config/GCPadNew.ini.xxx --> /storage/savefiles/User/Config/GCPadNew.ini
[INFO] [Environ]: SET_INPUT_DESCRIPTORS:
[libretro INFO] 42:47:412 Common/FileUtil.cpp:269 I[COMMON]: Rename: /storage/savefiles/User/Config/GCPadNew.ini.xxx --> /storage/savefiles/User/Config/GCPadNew.ini
[INFO] [Environ]: SET_INPUT_DESCRIPTORS:
[libretro INFO] 42:47:421 Common/FileUtil.cpp:269 I[COMMON]: Rename: /storage/savefiles/User/Config/GCPadNew.ini.xxx --> /storage/savefiles/User/Config/GCPadNew.ini
[INFO] [Environ]: SET_INPUT_DESCRIPTORS:
[libretro INFO] 42:47:429 Common/FileUtil.cpp:269 I[COMMON]: Rename: /storage/savefiles/User/Config/GCPadNew.ini.xxx --> /storage/savefiles/User/Config/GCPadNew.ini
[INFO] [Environ]: SET_INPUT_DESCRIPTORS:
[INFO] [SRAM]: Skipping SRAM load..
[INFO] Version of libretro API: 1
[INFO] Compiled against API: 1
[INFO] [Audio]: Set audio input rate to: 31270.51 Hz.
[INFO] [Video]: Video @ 1920x1080
[INFO] [Video]: Using HW render, vulkan driver forced.
[INFO] [Vulkan]: Vulkan dynamic library loaded.
[INFO] [Vulkan]: App: Dolphin-Emu (version 5)
[INFO] [Vulkan]: Engine: Dolphin-Emu (version 2)
[INFO] [Vulkan]: Found vulkan context: khr_display
[INFO] [Vulkan]: Detecting screen resolution 0x0.
[INFO] [Vulkan]: Found GPU at index 0: Intel(R) Iris(R) Pro Graphics 580 (SKL GT4)
[INFO] [Vulkan]: Using GPU index 0.
Segmentation fault

@gouchi
Copy link
Member

gouchi commented Sep 26, 2021

I can't reproduce the issue with nvidia driver under Xorg.

I tested with with homebrew Super Methane Brothers from content downloader.

So the issue will be related to Wayland and/or DRM/KMS only ?

@65a
Copy link

65a commented Sep 26, 2021

I can reproduce with KMS/Intel (Lakka) and Xorg/AMD (Arch). Same backtrace. It sounds like this might be everything but nVidia?

@RobertTheSable
Copy link
Author

I can't reproduce the issue with nvidia driver under Xorg.

I tested with with homebrew Super Methane Brothers from content downloader.

So the issue will be related to Wayland and/or DRM/KMS only ?

It's probably not Wayland since I wasn't using Wayland at the time of encountering the bug.

@gouchi
Copy link
Member

gouchi commented Sep 27, 2021

Alright I reproduced the issue using Intel HD and Vulkan. Here is the backtrace

#0  0x0000000000000000 in  ()
#1  0x00007fffeab455b7 in Vulkan::VulkanContext::PopulateShaderSubgroupSupport() (this=0x555556fcf2e0)
    at /home/lubuntu/Downloads/dolphin/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp:932
#2  0x00007fffeab43b15 in Vulkan::VulkanContext::Create(VkInstance_T*, VkPhysicalDevice_T*, VkSurfaceKHR_T*, bool, bool)
    (instance=0x555556722340, gpu=0x555556fcc770, surface=0x555556714930, enable_debug_reports=false, enable_validation_layer=false)
    at /home/lubuntu/Downloads/dolphin/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp:412
#3  0x00007fffea78c080 in Libretro::Video::Vk::CreateDevice(retro_vulkan_context*, VkInstance, VkPhysicalDevice, VkSurfaceKHR, PFN_vkGetInstanceProcAddr, char const**, unsigned int, char const**, unsigned int, VkPhysicalDeviceFeatures const*)                                                                                                                                        
    (context=0x7fffffffcf40, instance=0x555556722340, gpu=0x555556fcc770, surface=0x555556714930, get_instance_proc_addr=0x7fffe955be80 <vkGetInstanceProcAddr>, required_device_extensions=0x5555564a7ba0 <device_extensions>, num_required_device_extensions=1, required_device_layers=0x0, num_required_device_layers=0, required_features=0x7fffffffd0a0)
    at /home/lubuntu/Downloads/dolphin/Source/Core/DolphinLibretro/Video.cpp:277
#4  0x00005555559cae9f in vulkan_context_init_device (vk=0x55555678ce38) at gfx/common/vulkan_common.c:1629
#5  0x00005555559cca10 in vulkan_surface_create
    (vk=0x55555678ce38, type=VULKAN_WSI_XCB, display=0x555556701500, surface=0x555556592458 <g_x11_win>, width=1440, height=1016, swap_interval=1) at gfx/common/vulkan_common.c:2472
#6  0x00005555559900b8 in gfx_ctx_x_vk_set_video_mode (data=0x55555678ce30, width=1440, height=1080, fullscreen=false) at gfx/drivers_context/x_vk_ctx.c:426
#7  0x00005555559c017b in vulkan_init (video=0x7fffffffd730, input=0x5555564c7a80 <rarch_st>, input_data=0x5555564c7a88 <rarch_st+8>) at gfx/drivers/vulkan.c:1237
#8  0x000055555560a87a in video_driver_init_internal (p_rarch=0x5555564c7a80 <rarch_st>, settings=0x7fffed460010, video_is_threaded=0x7fffffffd7b3, verbosity_enabled=false)
    at retroarch.c:21060
#9  0x00005555556109fd in drivers_init (p_rarch=0x5555564c7a80 <rarch_st>, settings=0x7fffed460010, flags=2047, verbosity_enabled=false) at retroarch.c:23730
#10 0x00005555556171a3 in retroarch_main_init (argc=4, argv=0x7fffffffe028) at retroarch.c:26234
#11 0x000055555563b017 in content_load (info=0x7fffffffdee0, p_content=0x5555564e5190 <rarch_st+120592>) at tasks/task_content.c:1475
#12 0x000055555563cb76 in task_load_content_internal (content_info=0x7fffffffdee0, loading_from_menu=true, loading_from_cli=true, loading_from_companion_ui=false)
    at tasks/task_content.c:2342
#13 0x000055555563ce60 in task_push_load_content_from_cli (core_path=0x0, fullpath=0x0, content_info=0x7fffffffdee0, type=CORE_TYPE_PLAIN, cb=0x0, user_data=0x0)
    at tasks/task_content.c:2436
#14 0x00005555555f1755 in rarch_main (argc=4, argv=0x7fffffffe028, data=0x0) at retroarch.c:9694
#15 0x00005555555f17ec in main (argc=4, argv=0x7fffffffe028) at retroarch.c:9795

@65a
Copy link

65a commented Sep 28, 2021

The check at

if (!vkGetPhysicalDeviceProperties2 || (VK_VERSION_MAJOR(m_device_properties.apiVersion) == 1 &&
ensures that vkGetPhysicalDeviceProperties2 is non-null (if it was null, we'd return on a short circuit evaluation of the statement there).

Your stack trace seems to indicate that gpu is also non-null, and the other argument to vkGetPhysicalDeviceProperties2 is initialized in this function.

My best conclusion is that vkGetPhysicalDeviceProperties2 is unhappy with gpu (aka m_physical_device)?

@Igetin
Copy link

Igetin commented Mar 6, 2022

Just reporting that I’m experiencing this problem as well, on the latest master (3b19e6d).

OS: Fedora 35
Windowing system: X11
Graphics driver: ADMGPU
GPU: Radeon RX 6800 XT

The GL driver seems to work fine.

@gouchi
Copy link
Member

gouchi commented Sep 16, 2022

Here is the log with Vulkan Validation Layers using VULKAN_DEBUG=1


[ERROR] [Vulkan]: Validation Error: Validation Error: [ UNASSIGNED-API-Version-Violation ] Object 0: handle = 0x558be0232930, type = VK_OBJECT_TYPE_INSTANCE; | MessageID = 0xc495fcb4 | Attempted to call vkGetPhysicalDeviceProperties2() with an effective API version of 1.0.0 (0x00400000), which is the minimum of version requested in pApplicationInfo (1.0.0 (0x00400000)) and supported by this physical device (1.3.204 (0x004030cc)), but this API was not promoted until version 1.1.0 (0x00401000).
[ERROR] [Vulkan]: Validation Error: Validation Error: [ VUID-VkPhysicalDeviceProperties2-pNext-pNext ] Object 0: handle = 0x558be0232930, type = VK_OBJECT_TYPE_INSTANCE; | MessageID = 0xdd73dbcf | vkGetPhysicalDeviceProperties2: Includes a pNext pointer (pProperties->pNext) to a VkStructureType (VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES) which was added in VK_API_VERSION_1_1 but the current effective API version is 1.0.0 (0x00400000). The Vulkan spec states: Each pNext member of any structure (including this one) in the pNext chain must be either NULL or a pointer to a valid instance of VkPhysicalDeviceAccelerationStructurePropertiesKHR, VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT, VkPhysicalDeviceConservativeRasterizationPropertiesEXT, VkPhysicalDeviceCooperativeMatrixPropertiesNV, VkPhysicalDeviceCustomBorderColorPropertiesEXT, VkPhysicalDeviceDepthStencilResolveProperties, VkPhysicalDeviceDescriptorIndexingProperties, VkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV, VkPhysicalDeviceDiscardRectanglePropertiesEXT, VkPhysicalDeviceDriverProperties, VkPhysicalDeviceDrmPropertiesEXT, VkPhysicalDeviceExternalMemoryHostPropertiesEXT, VkPhysicalDeviceFloatControlsProperties, VkPhysicalDeviceFragmentDensityMap2PropertiesEXT, VkPhysicalDeviceFragmentDensityMapOffsetPropertiesQCOM, VkPhysicalDeviceFragmentDensityMapPropertiesEXT, VkPhysicalDeviceFragmentShadingRateEnumsPropertiesNV, VkPhysicalDeviceFragmentShadingRatePropertiesKHR, VkPhysicalDeviceIDProperties, VkPhysicalDeviceInlineUniformBlockProperties, VkPhysicalDeviceLineRasterizationPropertiesEXT, VkPhysicalDeviceMaintenance3Properties, VkPhysicalDeviceMaintenance4Properties, VkPhysicalDeviceMeshShaderPropertiesNV, VkPhysicalDeviceMultiDrawPropertiesEXT, VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX, VkPhysicalDeviceMultiviewProperties, VkPhysicalDevicePCIBusInfoPropertiesEXT, VkPhysicalDevicePerformanceQueryPropertiesKHR, VkPhysicalDevicePointClippingProperties, VkPhysicalDevicePortabilitySubsetPropertiesKHR, VkPhysicalDeviceProtectedMemoryProperties, VkPhysicalDeviceProvokingVertexPropertiesEXT, VkPhysicalDevicePushDescriptorPropertiesKHR, VkPhysicalDeviceRayTracingPipelinePropertiesKHR, VkPhysicalDeviceRayTracingPropertiesNV, VkPhysicalDeviceRobustness2PropertiesEXT, VkPhysicalDeviceSampleLocationsPropertiesEXT, VkPhysicalDeviceSamplerFilterMinmaxProperties, VkPhysicalDeviceShaderCoreProperties2AMD, VkPhysicalDeviceShaderCorePropertiesAMD, VkPhysicalDeviceShaderIntegerDotProductProperties, VkPhysicalDeviceShaderSMBuiltinsPropertiesNV, VkPhysicalDeviceShadingRateImagePropertiesNV, VkPhysicalDeviceSubgroupProperties, VkPhysicalDeviceSubgroupSizeControlProperties, VkPhysicalDeviceSubpassShadingPropertiesHUAWEI, VkPhysicalDeviceTexelBufferAlignmentProperties, VkPhysicalDeviceTimelineSemaphoreProperties, VkPhysicalDeviceTransformFeedbackPropertiesEXT, VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT, VkPhysicalDeviceVulkan11Properties, VkPhysicalDeviceVulkan12Properties, or VkPhysicalDeviceVulkan13Properties (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkPhysicalDeviceProperties2-pNext-pNext)

@gouchi
Copy link
Member

gouchi commented Sep 25, 2022

@RobertTheSable The issue should be renamed to Launching with Mesa Vulkan driver causes a segfault. Thank you.

It seems vkGetPhysicalDeviceProperties2 is coming from Vulkan 1.1 but we are using Vulkan 1.0 context ?

But why it would work with Nvidia Vulkan driver ?

@Sanaki
Copy link

Sanaki commented Sep 25, 2022

Verified this on the steam version on steam deck. Seems like it should be as simple as switching to requesting a 1.1 context then, right? Or am I missing something?

@gouchi
Copy link
Member

gouchi commented Feb 4, 2023

I confirm this issue is fixed with this PR.

So running latest master or future RA 1.15.0 will fix this issue.

@gouchi
Copy link
Member

gouchi commented Apr 29, 2023

@RobertTheSable Please close this issue as it has been fixed.

Thank you.

Kind regards,

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