Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Wayland segfault

110 views
Skip to first unread message

Joel Winarske

unread,
Feb 27, 2023, 5:55:02 PM2/27/23
to swiftshader
I'm seeing a Segfault on Linux Wayland Session with master.

To repro simply run vulkaninfo with swiftshader installed in a Wayland session.

In case of Ubuntu 20 and Fedora 37 build is via:
CC=/usr/lib/llvm-14/bin/clang CXX=/usr/lib/llvm-14/bin/clang++ cmake .. -DSWIFTSHADER_BUILD_WSI_XCB=OFF -DSWIFTSHADER_BUILD_WSI_WAYLAND=ON -DSWIFTSHADER_WARNINGS_AS_ERRORS=FALSE

Segfault happens at:
WaylandSurfaceKHR::WaylandSurfaceKHR(const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, void *mem)
: display(pCreateInfo->display)
, surface(pCreateInfo->surface)
{
struct wl_registry *registry = libWaylandClient->wl_display_get_registry(display);


Joel Winarske

unread,
Feb 27, 2023, 7:22:18 PM2/27/23
to swiftshader
Stacktrace
-----------------------------------------------------
<unknown> 0x0000000000000000
vk::WaylandSurfaceKHR::WaylandSurfaceKHR WaylandSurfaceKHR.cpp:51
vk::Create<…> VkObject.hpp:65
vk::ObjectBase::Create<…> VkObject.hpp:92
vkCreateWaylandSurfaceKHR libVulkan.cpp:4357
terminator_CreateWaylandSurfaceKHR 0x00007ffff7cd747d
AppCreateWaylandSurface vulkaninfo.h:1012
main vulkaninfo.cpp:1104
__libc_start_call_main 0x00007ffff784a510
__libc_start_main_impl 0x00007ffff784a5c9
_start 0x00000000004048a5

Variables
-----------------------------------------------------
Signal = SIGSEGV (Segmentation fault)
this = {vk::WaylandSurfaceKHR *} 0x5f8d88
 vk::SurfaceKHR = {vk::SurfaceKHR}
 vk::ObjectBase<vk::WaylandSurfaceKHR, VkNonDispatchableHandle<VkSurfaceKHR_T*> > = {vk::ObjectBase<vk::WaylandSurfaceKHR, VkNonDispatchableHandle<VkSurfaceKHR_T *>>}
 display = {wl_display *} 0x58c480
 surface = {wl_surface *} 0x58bc40
 shm = {wl_shm *} NULL
 imageMap = {std::unordered_map<vk::PresentImage *, vk::WaylandImage *, std::hash<vk::PresentImage *>, std::equal_to<vk::PresentImage *>, std::allocator<std::pair<vk::PresentImage *const, vk::WaylandImage *>>>}
pCreateInfo = {const VkWaylandSurfaceCreateInfoKHR *} 0x7fffffffd870
 sType = {VkStructureType} VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR
 pNext = {const void *} NULL
 flags = {VkWaylandSurfaceCreateFlagsKHR} 0 [0x0]
 display = {wl_display *} 0x58c480
 surface = {wl_surface *} 0x58bc40
mem = {void *} NULL

The definition of wl_display_get_registry is in a header file generated by wayland scanner from a protocol (xml) file.  So this isn't available as a symbol from libwayland.so.  I'm suspecting it's available with wlroots...

So this code is the problem, as the function pointer is never resolved -> nullptr.

struct wl_registry *registry = libWaylandClient->wl_display_get_registry(display);

$ readelf -a -W libwayland-client.so.0.21.0 |grep wl_display_get_registry
[joel@air lib64]$
[joel@air lib64]$ readelf -a -W libwayland-client.so.0.21.0 |grep wl_proxy_marshal_flags
0000000000010e58  0000003800000007 R_X86_64_JUMP_SLOT     000000000000b130 wl_proxy_marshal_flags + 0
    56: 000000000000b130   275 FUNC    GLOBAL DEFAULT   14 wl_proxy_marshal_flags
[joel@air lib64]$ readelf -a -W libwayland-client.so.0.21.0 |grep wl_proxy_get_version
0000000000010dd0  0000004700000007 R_X86_64_JUMP_SLOT     00000000000081c0 wl_proxy_get_version + 0
    71: 00000000000081c0     8 FUNC    GLOBAL DEFAULT   14 wl_proxy_get_version
[joel@air lib64]$ readelf -a -W libwayland-client.so.0.21.0 |grep wl_registry_interface
0000000000011048  0000005600000001 R_X86_64_64            0000000000010a40 wl_registry_interface + 0
    86: 0000000000010a40    40 OBJECT  GLOBAL DEFAULT   21 wl_registry_interface


So the only solution I see is to implement wl_display_get_registry in swiftshader.

From wayland-client-protocol.h:
static inline struct wl_registry *
wl_display_get_registry(struct wl_display *wl_display)
{
struct wl_proxy *registry;

registry = wl_proxy_marshal_flags((struct wl_proxy *) wl_display,
WL_DISPLAY_GET_REGISTRY, &wl_registry_interface, wl_proxy_get_version((struct wl_proxy *) wl_display), 0, NULL);

return (struct wl_registry *) registry;
}



--
You received this message because you are subscribed to a topic in the Google Groups "swiftshader" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/swiftshader/KjeO6rIUMzY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to swiftshader...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/swiftshader/e8515e36-72f0-47f4-868d-0b4981942089n%40googlegroups.com.

Joel Winarske

unread,
Feb 27, 2023, 11:20:24 PM2/27/23
to swiftshader
If I import wl_proxy_marshal_flags, wl_prox_get_version, wl_registry_interface, etc and implement as with above pattern I can make it work.   It would be helpful to know more about the Wayland environment that it was developed for.  It's very clear it was not libweston (Ubuntu/Fedora/AGL/Poky etc).

Joel Winarske

unread,
Feb 28, 2023, 2:06:44 PM2/28/23
to swiftshader
I have a patch that works on Fedora 37 and Ubuntu 20.  Both distros are running the default runtime packages.

I'll submit a change to Gerrit in the next couple of days.
Reply all
Reply to author
Forward
0 new messages