aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-03-18 10:10:50 +0100
committerGitHub Enterprise <[email protected]>2026-03-18 10:10:50 +0100
commit0faf85c9d83c85c18aa72e19458356bf9e45c59b (patch)
tree1c2aba035aafa8526a5b8e28e2b0429099b84ef4 /src
parentfix for GHES failing on upload-artifacts@v3 (#856) (diff)
downloadzen-0faf85c9d83c85c18aa72e19458356bf9e45c59b.tar.xz
zen-0faf85c9d83c85c18aa72e19458356bf9e45c59b.zip
bugfix release - v5.7.23 (#851)
Works around issue where we could crash during startup when the logging system wasn't fully initialized and something used `ZEN_INFO` et al
Diffstat (limited to 'src')
-rw-r--r--src/zencore/sentryintegration.cpp8
-rw-r--r--src/zenserver/zenserver.cpp78
-rw-r--r--src/zenutil/zenserverprocess.cpp20
3 files changed, 64 insertions, 42 deletions
diff --git a/src/zencore/sentryintegration.cpp b/src/zencore/sentryintegration.cpp
index b7d01003b..634045cfb 100644
--- a/src/zencore/sentryintegration.cpp
+++ b/src/zencore/sentryintegration.cpp
@@ -248,6 +248,14 @@ SentryIntegration::Initialize(const Config& Conf, const std::string& CommandLine
}
sentry_options_t* SentryOptions = sentry_options_new();
+ if (SentryOptions == nullptr)
+ {
+ // OOM — skip sentry entirely rather than crashing on the subsequent set calls
+ m_SentryErrorCode = -1;
+ m_IsInitialized = true;
+ return;
+ }
+
sentry_options_set_dsn(SentryOptions, Conf.Dsn.empty() ? sentry::DefaultDsn.c_str() : Conf.Dsn.c_str());
sentry_options_set_database_path(SentryOptions, SentryDatabasePath.c_str());
sentry_options_set_logger(SentryOptions, SentryLogFunction, this);
diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp
index 1cd8ed846..fe6a5a572 100644
--- a/src/zenserver/zenserver.cpp
+++ b/src/zenserver/zenserver.cpp
@@ -631,6 +631,10 @@ ZenServerMain::Run()
uint32_t AttachSponsorProcessRetriesLeft = 3;
ZenServerState::ZenServerEntry* Entry = ServerState.Lookup(m_ServerOptions.BasePort);
+ // NOTE: ZEN_CONSOLE_WARN/INFO is used in this block and the lock file block below
+ // (instead of ZEN_WARN/INFO) because InitializeLogging() has not been called yet at
+ // this point. ZEN_WARN/INFO would silently discard messages before the logging system
+ // is initialized.
while (Entry)
{
if (m_ServerOptions.OwnerPid)
@@ -640,27 +644,29 @@ ZenServerMain::Run()
{
if (Ec)
{
- ZEN_WARN(ZEN_APP_NAME
- " exiting, sponsor owner pid {} can not be checked for running state, reason: '{}'. Will not add sponsor "
- "to process "
- "listening to port {} (pid: {})",
- m_ServerOptions.OwnerPid,
- Ec.message(),
- m_ServerOptions.BasePort,
- Entry->Pid.load());
+ ZEN_CONSOLE_WARN(
+ ZEN_APP_NAME
+ " exiting, sponsor owner pid {} can not be checked for running state, reason: '{}'. Will not add sponsor "
+ "to process "
+ "listening to port {} (pid: {})",
+ m_ServerOptions.OwnerPid,
+ Ec.message(),
+ m_ServerOptions.BasePort,
+ Entry->Pid.load());
}
else
{
- ZEN_WARN(ZEN_APP_NAME
- " exiting, sponsor owner pid {} is no longer running, will not add sponsor to process listening to port "
- "{} (pid: {})",
- m_ServerOptions.OwnerPid,
- m_ServerOptions.BasePort,
- Entry->Pid.load());
+ ZEN_CONSOLE_WARN(
+ ZEN_APP_NAME
+ " exiting, sponsor owner pid {} is no longer running, will not add sponsor to process listening to port "
+ "{} (pid: {})",
+ m_ServerOptions.OwnerPid,
+ m_ServerOptions.BasePort,
+ Entry->Pid.load());
}
std::exit(1);
}
- ZEN_INFO(
+ ZEN_CONSOLE_INFO(
"Looks like there is already a process listening to this port {} (pid: {}), attaching owner pid {} to running instance",
m_ServerOptions.BasePort,
Entry->Pid.load(),
@@ -678,18 +684,18 @@ ZenServerMain::Run()
}
else
{
- ZEN_WARN(ZEN_APP_NAME " exiting, failed to add sponsor owner pid {} to process listening to port {} (pid: {})",
- m_ServerOptions.OwnerPid,
- m_ServerOptions.BasePort,
- Entry->Pid.load());
+ ZEN_CONSOLE_WARN(ZEN_APP_NAME " exiting, failed to add sponsor owner pid {} to process listening to port {} (pid: {})",
+ m_ServerOptions.OwnerPid,
+ m_ServerOptions.BasePort,
+ Entry->Pid.load());
std::exit(1);
}
}
else
{
- ZEN_WARN(ZEN_APP_NAME " exiting, there is already a process listening to port {} (pid: {})",
- m_ServerOptions.BasePort,
- Entry->Pid.load());
+ ZEN_CONSOLE_WARN(ZEN_APP_NAME " exiting, there is already a process listening to port {} (pid: {})",
+ m_ServerOptions.BasePort,
+ Entry->Pid.load());
std::exit(1);
}
}
@@ -702,19 +708,19 @@ ZenServerMain::Run()
if (Ec)
{
- ZEN_INFO(ZEN_APP_NAME " unable to grab lock at '{}' (reason: '{}'), retrying", LockFilePath, Ec.message());
+ ZEN_CONSOLE_INFO(ZEN_APP_NAME " unable to grab lock at '{}' (reason: '{}'), retrying", LockFilePath, Ec.message());
Sleep(100);
m_LockFile.Create(LockFilePath, MakeLockData(false), Ec);
if (Ec)
{
- ZEN_INFO(ZEN_APP_NAME " unable to grab lock at '{}' (reason: '{}'), retrying", LockFilePath, Ec.message());
+ ZEN_CONSOLE_INFO(ZEN_APP_NAME " unable to grab lock at '{}' (reason: '{}'), retrying", LockFilePath, Ec.message());
Sleep(500);
m_LockFile.Create(LockFilePath, MakeLockData(false), Ec);
if (Ec)
{
- ZEN_WARN(ZEN_APP_NAME " exiting, unable to grab lock at '{}' (reason: '{}')", LockFilePath, Ec.message());
+ ZEN_CONSOLE_WARN(ZEN_APP_NAME " exiting, unable to grab lock at '{}' (reason: '{}')", LockFilePath, Ec.message());
std::exit(99);
}
}
@@ -736,6 +742,12 @@ ZenServerMain::Run()
Entry = ServerState.Register(m_ServerOptions.BasePort);
+ if (!Entry)
+ {
+ throw std::runtime_error(
+ fmt::format("Failed to register server on port {} in shared state (all slots occupied)", m_ServerOptions.BasePort));
+ }
+
// Publish per-instance extended info (e.g. UDS path) via a small shared memory
// section keyed by SessionId so clients can discover it during Snapshot() enumeration.
{
@@ -762,22 +774,22 @@ ZenServerMain::Run()
}
catch (const AssertException& AssertEx)
{
- ZEN_CRITICAL(ZEN_APP_NAME " caught assert exception in main for process {}: {}",
- zen::GetCurrentProcessId(),
- AssertEx.FullDescription());
+ ZEN_CONSOLE_CRITICAL(ZEN_APP_NAME " caught assert exception in main for process {}: {}",
+ zen::GetCurrentProcessId(),
+ AssertEx.FullDescription());
RequestApplicationExit(1);
}
catch (const std::system_error& e)
{
- ZEN_CRITICAL(ZEN_APP_NAME " caught system error exception in main for process {}: {} ({})",
- zen::GetCurrentProcessId(),
- e.what(),
- e.code().value());
+ ZEN_CONSOLE_CRITICAL(ZEN_APP_NAME " caught system error exception in main for process {}: {} ({})",
+ zen::GetCurrentProcessId(),
+ e.what(),
+ e.code().value());
RequestApplicationExit(1);
}
catch (const std::exception& e)
{
- ZEN_CRITICAL(ZEN_APP_NAME " caught exception in main for process {}: {}", zen::GetCurrentProcessId(), e.what());
+ ZEN_CONSOLE_CRITICAL(ZEN_APP_NAME " caught exception in main for process {}: {}", zen::GetCurrentProcessId(), e.what());
RequestApplicationExit(1);
}
diff --git a/src/zenutil/zenserverprocess.cpp b/src/zenutil/zenserverprocess.cpp
index ac614f779..e0d99c981 100644
--- a/src/zenutil/zenserverprocess.cpp
+++ b/src/zenutil/zenserverprocess.cpp
@@ -368,14 +368,16 @@ ZenServerState::Sweep()
{
if (ErrorCode)
{
- ZEN_WARN("Sweep - can not determine running state for pid {}, skipping entry (port {}). Reason: '{}'",
- Entry.Pid.load(),
- Entry.DesiredListenPort.load(),
- ErrorCode.message());
+ ZEN_CONSOLE_WARN("Sweep - can not determine running state for pid {}, skipping entry (port {}). Reason: '{}'",
+ Entry.Pid.load(),
+ Entry.DesiredListenPort.load(),
+ ErrorCode.message());
}
else
{
- ZEN_DEBUG("Sweep - pid {} not running, reclaiming entry (port {})", Entry.Pid.load(), Entry.DesiredListenPort.load());
+ ZEN_CONSOLE_DEBUG("Sweep - pid {} not running, reclaiming entry (port {})",
+ Entry.Pid.load(),
+ Entry.DesiredListenPort.load());
Entry.Reset();
}
}
@@ -402,10 +404,10 @@ ZenServerState::Snapshot(std::function<void(const ZenServerEntry&)>&& Callback)
{
if (ErrorCode)
{
- ZEN_WARN("Snapshot - can not determine running state for pid {}, skipping entry (port {}). Reason: '{}'",
- Entry.Pid.load(),
- Entry.DesiredListenPort.load(),
- ErrorCode.message());
+ ZEN_CONSOLE_WARN("Snapshot - can not determine running state for pid {}, skipping entry (port {}). Reason: '{}'",
+ Entry.Pid.load(),
+ Entry.DesiredListenPort.load(),
+ ErrorCode.message());
}
else
{