Skip to content

Commit

Permalink
protocols: avoid crashing in drmlease
Browse files Browse the repository at this point in the history
instead of potentially causing wonky behaviour from destructing in the
constructor add the unique_ptr reset to doLater and dont use the not
done constructed protolog in the constructor, call Debug::log directly.

see issue #7240
  • Loading branch information
gulafaran committed Aug 12, 2024
1 parent 4fdc0d5 commit abe9210
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/managers/ProtocolManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ CProtocolManager::CProtocolManager() {
continue;

PROTO::lease = std::make_unique<CDRMLeaseProtocol>(&wp_drm_lease_device_v1_interface, 1, "DRMLease");

if (*PENABLEEXPLICIT)
PROTO::sync = std::make_unique<CDRMSyncobjProtocol>(&wp_linux_drm_syncobj_manager_v1_interface, 1, "DRMSyncobj");
break;
Expand Down
9 changes: 4 additions & 5 deletions src/protocols/DRMLease.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "DRMLease.hpp"
#include "../Compositor.hpp"
#include "managers/eventLoop/EventLoopManager.hpp"
#include <aquamarine/backend/DRM.hpp>
#include <fcntl.h>

Expand Down Expand Up @@ -225,7 +226,7 @@ CDRMLeaseDevice::CDRMLeaseDevice(SP<Aquamarine::CDRMBackend> drmBackend) : backe
auto fd = drm->getNonMasterFD();

if (fd < 0) {
LOGM(ERR, "Failed to dup fd for drm node {}", drm->gpuName);
Debug::log(ERR, "[DRMLease] Failed to dup fd for drm node {}", drm->gpuName);
return;
}

Expand All @@ -247,10 +248,8 @@ CDRMLeaseProtocol::CDRMLeaseProtocol(const wl_interface* iface, const int& ver,
break;
}

if (!primaryDevice || primaryDevice->success) {
PROTO::lease.reset();
return;
}
if (!primaryDevice || !primaryDevice->success)
g_pEventLoopManager->doLater([]() { PROTO::lease.reset(); });
}

void CDRMLeaseProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
Expand Down

0 comments on commit abe9210

Please sign in to comment.