Skip to content

Commit

Permalink
steamcompmgr: fix another coredump-at-exit
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkautarch committed Dec 12, 2024
1 parent 3ca06f6 commit 06abe14
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace gamescope
bool IBackend::Set( IBackend *pBackend )
{
if ( s_pBackend ) {
GetBackend()->IBackend::~IBackend();
std::destroy_at(GetBackend());
}

if ( pBackend )
Expand Down
23 changes: 19 additions & 4 deletions src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5898,6 +5898,23 @@ error(Display *dpy, XErrorEvent *ev)
[[noreturn]] static void
steamcompmgr_exit(std::optional<std::unique_lock<std::mutex>> lock = std::nullopt)
{

// Need to clear all the vk_lutxd references (which can be tied to backend-allocated memory)
// for the colormgmt globals/statics, to avoid coredump at exit from within the colormgmt exit-time destructors:
for (auto& colorMgmtArr :
{
std::ref(g_ColorMgmtLuts),
std::ref(g_ColorMgmtLutsOverride),
std::ref(g_ScreenshotColorMgmtLuts),
std::ref(g_ScreenshotColorMgmtLutsHDR)
})
{
for (auto& colorMgmt : colorMgmtArr.get())
{
colorMgmt.gamescope_color_mgmt_luts::~gamescope_color_mgmt_luts(); //dtor call also calls all the subobjects' dtors
}
}

g_ImageWaiter.Shutdown();

// Clean up any commits.
Expand All @@ -5922,23 +5939,21 @@ steamcompmgr_exit(std::optional<std::unique_lock<std::mutex>> lock = std::nullop
{
g_ColorMgmt.pending.appHDRMetadata = nullptr;
g_ColorMgmt.current.appHDRMetadata = nullptr;

s_scRGB709To2020Matrix = nullptr;
for (int i = 0; i < gamescope::GAMESCOPE_SCREEN_TYPE_COUNT; i++)
{
s_MuraCorrectionImage[i] = nullptr;
s_MuraCTMBlob[i] = nullptr;
}
}

if (lock)
lock->unlock();
gamescope::IBackend::Set( nullptr );

wlserver_lock();
wlserver_shutdown();
wlserver_unlock(false);

if (lock)
lock->unlock();
pthread_exit(NULL);
}

Expand Down

0 comments on commit 06abe14

Please sign in to comment.