Skip to content

Commit 7061418

Browse files
committed
wlserver: Fix syncobj crash
Some apps do destruction on other queues which breaks stuff here. Instead handle m_pWlSurfaceInfo being NULL elegantly from both sides.
1 parent 9416ca9 commit 7061418

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/WaylandServer/LinuxDrmSyncobj.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ namespace gamescope::WaylandServer
4545

4646
~CLinuxDrmSyncobjSurface()
4747
{
48-
assert( m_pWlSurfaceInfo->pSyncobjSurface == this );
49-
m_pWlSurfaceInfo->pSyncobjSurface = nullptr;
48+
Detach();
5049
}
5150

5251
bool HasExplicitSync() const
@@ -70,6 +69,17 @@ namespace gamescope::WaylandServer
7069
return std::make_shared<CReleaseTimelinePoint>( m_pReleaseTimeline, m_ulReleasePoint );
7170
}
7271

72+
void Detach()
73+
{
74+
if ( m_pWlSurfaceInfo )
75+
{
76+
assert( m_pWlSurfaceInfo->pSyncobjSurface == this );
77+
m_pWlSurfaceInfo->pSyncobjSurface = nullptr;
78+
}
79+
80+
m_pWlSurfaceInfo = nullptr;
81+
}
82+
7383
protected:
7484

7585
void SetAcquirePoint( wl_resource *pWlTimeline, uint32_t uPointHi, uint32_t uPointLo )

src/wlserver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,8 @@ static void handle_wl_surface_destroy( struct wl_listener *l, void *data )
599599

600600
if ( surf->pSyncobjSurface )
601601
{
602-
wl_resource_destroy( surf->pSyncobjSurface->GetResource() );
602+
surf->pSyncobjSurface->Detach();
603+
assert( surf->pSyncobjSurface == nullptr );
603604
}
604605

605606
surf->wlr->data = nullptr;

0 commit comments

Comments
 (0)