diff options
| author | Dan Engelbrecht <[email protected]> | 2024-04-04 14:32:40 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-04-04 14:32:40 +0200 |
| commit | 12b7bf1c16f671c83840961c37a339141a7ffbb3 (patch) | |
| tree | 3c503e6e1cd4d53b87c1baebcf9286ca8b72db06 /src/zenstore | |
| parent | hardening parsepackagemessage (#38) (diff) | |
| download | zen-12b7bf1c16f671c83840961c37a339141a7ffbb3.tar.xz zen-12b7bf1c16f671c83840961c37a339141a7ffbb3.zip | |
improved assert (#37)
- Improvement: Add file and line to ASSERT exceptions
- Improvement: Catch call stack when throwing assert exceptions and log/output call stack at important places to provide more context to caller
Diffstat (limited to 'src/zenstore')
| -rw-r--r-- | src/zenstore/blockstore.cpp | 6 | ||||
| -rw-r--r-- | src/zenstore/cache/cachedisklayer.cpp | 22 | ||||
| -rw-r--r-- | src/zenstore/cache/structuredcachestore.cpp | 4 | ||||
| -rw-r--r-- | src/zenstore/compactcas.cpp | 4 | ||||
| -rw-r--r-- | src/zenstore/filecas.cpp | 2 | ||||
| -rw-r--r-- | src/zenstore/gc.cpp | 32 |
6 files changed, 35 insertions, 35 deletions
diff --git a/src/zenstore/blockstore.cpp b/src/zenstore/blockstore.cpp index dfa852434..a576ff022 100644 --- a/src/zenstore/blockstore.cpp +++ b/src/zenstore/blockstore.cpp @@ -915,7 +915,7 @@ BlockStore::ReclaimSpace(const ReclaimSnapshotState& Snapshot, NewBlockFile = nullptr; } } - catch (std::system_error& SystemError) + catch (const std::system_error& SystemError) { if (IsOOM(SystemError.code())) { @@ -930,11 +930,11 @@ BlockStore::ReclaimSpace(const ReclaimSnapshotState& Snapshot, ZEN_ERROR("reclaiming space for '{}' failed with system error exception: '{}'", m_BlocksBasePath, SystemError.what()); } } - catch (std::bad_alloc& BadAlloc) + catch (const std::bad_alloc& BadAlloc) { ZEN_WARN("reclaiming space for '{}' ran out of memory: '{}'", m_BlocksBasePath, BadAlloc.what()); } - catch (std::exception& ex) + catch (const std::exception& ex) { ZEN_ERROR("reclaiming space for '{}' failed with: '{}'", m_BlocksBasePath, ex.what()); } diff --git a/src/zenstore/cache/cachedisklayer.cpp b/src/zenstore/cache/cachedisklayer.cpp index 3605f5582..f53ab6f8b 100644 --- a/src/zenstore/cache/cachedisklayer.cpp +++ b/src/zenstore/cache/cachedisklayer.cpp @@ -871,7 +871,7 @@ ZenCacheDiskLayer::CacheBucket::WriteIndexSnapshotLocked(const std::function<uin m_LogFlushPosition = LogCount; } } - catch (std::exception& Err) + catch (const std::exception& Err) { ZEN_WARN("snapshot FAILED, reason: '{}'", Err.what()); } @@ -1434,7 +1434,7 @@ ZenCacheDiskLayer::CacheBucket::Flush() SaveSnapshot(); } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_WARN("Failed to flush bucket in '{}'. Reason: '{}'", m_BucketDir, Ex.what()); } @@ -1540,7 +1540,7 @@ ZenCacheDiskLayer::CacheBucket::SaveSnapshot(const std::function<uint64_t()>& Cl std::filesystem::path ManifestPath = GetManifestPath(m_BucketDir, m_BucketName); WriteFile(ManifestPath, Buffer); } - catch (std::exception& Err) + catch (const std::exception& Err) { ZEN_WARN("writing manifest in '{}' FAILED, reason: '{}'", m_BucketDir, Err.what()); } @@ -1985,7 +1985,7 @@ ZenCacheDiskLayer::CacheBucket::CollectGarbage(GcContext& GcCtx) { SaveSnapshot([&]() { return GcCtx.ClaimGCReserve(); }); } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_WARN("Failed to write index and manifest after GC in '{}'. Reason: '{}'", m_BucketDir, Ex.what()); } @@ -2921,7 +2921,7 @@ ZenCacheDiskLayer::CacheBucket::RemoveExpiredData(GcCtx& Ctx, GcStats& Stats) { SaveSnapshot([]() { return 0; }); } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_WARN("Failed to write index and manifest after RemoveExpiredData in '{}'. Reason: '{}'", m_BucketDir, Ex.what()); } @@ -3034,7 +3034,7 @@ public: m_IndexLock.reset(); m_CacheBucket.m_IndexLock.WithExclusiveLock([&]() { m_CacheBucket.m_TrackedReferences.reset(); }); } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_ERROR("~DiskBucketReferenceChecker threw exception: '{}'", Ex.what()); } @@ -3367,7 +3367,7 @@ ZenCacheDiskLayer::~ZenCacheDiskLayer() // This can cause a deadlock, if GC is running we would block while holding ZenCacheDiskLayer::m_Lock m_DroppedBuckets.clear(); } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_ERROR("~ZenCacheDiskLayer() failed. Reason: '{}'", Ex.what()); } @@ -3491,7 +3491,7 @@ ZenCacheDiskLayer::DiscoverBuckets() { IsOk = DeleteDirectories(BadBucketPath); } - catch (std::exception&) + catch (const std::exception&) { } @@ -3634,14 +3634,14 @@ ZenCacheDiskLayer::Flush() { Bucket->Flush(); } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_ERROR("Failed flushing bucket. Reason: '{}'", Ex.what()); } }); } } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_ERROR("Failed to flush buckets at '{}'. Reason: '{}'", m_RootDir, Ex.what()); } @@ -3878,7 +3878,7 @@ ZenCacheDiskLayer::MemCacheTrim() } }); } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_ERROR("Failed scheduling ZenCacheDiskLayer::MemCacheTrim. Reason: '{}'", Ex.what()); m_IsMemCacheTrimming.store(false); diff --git a/src/zenstore/cache/structuredcachestore.cpp b/src/zenstore/cache/structuredcachestore.cpp index daa628f77..c4ee6f4d3 100644 --- a/src/zenstore/cache/structuredcachestore.cpp +++ b/src/zenstore/cache/structuredcachestore.cpp @@ -400,7 +400,7 @@ ZenCacheStore::LogWorker() ObjectSize, ToString(Item.Value.Value.GetContentType())) } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_LOG_INFO(LogCacheActivity, "{} [{}] {}/{}/{} failed: Reason: '{}'", @@ -436,7 +436,7 @@ ZenCacheStore::LogWorker() m_LogEvent.Wait(); m_LogEvent.Reset(); } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_WARN("Log writer failed: '{}'", Ex.what()); } diff --git a/src/zenstore/compactcas.cpp b/src/zenstore/compactcas.cpp index 17cf20e35..84905df15 100644 --- a/src/zenstore/compactcas.cpp +++ b/src/zenstore/compactcas.cpp @@ -338,7 +338,7 @@ CasContainerStrategy::ScrubStorage(ScrubContext& Ctx) m_BlockStore.IterateChunks(ChunkLocations, ValidateSmallChunk, ValidateLargeChunk); } - catch (ScrubDeadlineExpiredException&) + catch (const ScrubDeadlineExpiredException&) { ZEN_INFO("Scrubbing deadline expired, operation incomplete"); } @@ -934,7 +934,7 @@ CasContainerStrategy::MakeIndexSnapshot() EntryCount = Entries.size(); m_LogFlushPosition = IndexLogPosition; } - catch (std::exception& Err) + catch (const std::exception& Err) { ZEN_WARN("snapshot FAILED, reason: '{}'", Err.what()); diff --git a/src/zenstore/filecas.cpp b/src/zenstore/filecas.cpp index 6b4185ff4..0f3e2ab5a 100644 --- a/src/zenstore/filecas.cpp +++ b/src/zenstore/filecas.cpp @@ -1210,7 +1210,7 @@ FileCasStrategy::MakeIndexSnapshot() EntryCount = Entries.size(); m_LogFlushPosition = IndexLogPosition; } - catch (std::exception& Err) + catch (const std::exception& Err) { ZEN_WARN("snapshot FAILED, reason: '{}'", Err.what()); diff --git a/src/zenstore/gc.cpp b/src/zenstore/gc.cpp index 1a34019fb..d51144a5a 100644 --- a/src/zenstore/gc.cpp +++ b/src/zenstore/gc.cpp @@ -663,7 +663,7 @@ GcManager::CollectGarbage(const GcSettings& Settings) StoreCompactors.insert_or_assign(std::move(StoreCompactor), &Stats->second.CompactStoreStats); } } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_ERROR("GCV2: Failed removing expired data for {}. Reason: '{}'", Owner->GetGcName(Ctx), Ex.what()); } @@ -733,7 +733,7 @@ GcManager::CollectGarbage(const GcSettings& Settings) ReferencePruners.insert_or_assign(Index, std::move(ReferencePruner)); } } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_ERROR("GCV2: Failed creating reference pruners for {}. Reason: '{}'", ReferenceStore->GetGcName(Ctx), @@ -806,7 +806,7 @@ GcManager::CollectGarbage(const GcSettings& Settings) } } } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_ERROR("GCV2: Failed creating reference checkers for {}. Reason: '{}'", Referencer->GetGcName(Ctx), @@ -863,7 +863,7 @@ GcManager::CollectGarbage(const GcSettings& Settings) SCOPED_TIMER(Stats->second.PreCacheStateMS = std::chrono::milliseconds(Timer.GetElapsedTimeMs());); Checker->PreCache(Ctx); } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_ERROR("GCV2: Failed precaching for {}. Reason: '{}'", Checker->GetGcName(Ctx), Ex.what()); } @@ -919,7 +919,7 @@ GcManager::CollectGarbage(const GcSettings& Settings) SCOPED_TIMER(Stats->second.LockStateMS = std::chrono::milliseconds(Timer.GetElapsedTimeMs());); Checker->LockState(Ctx); } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_ERROR("GCV2: Failed locking state for {}. Reason: '{}'", Checker->GetGcName(Ctx), Ex.what()); } @@ -997,7 +997,7 @@ GcManager::CollectGarbage(const GcSettings& Settings) StoreCompactors.insert_or_assign(std::move(StoreCompactor), &Stats->CompactStoreStats); } } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_ERROR("GCV2: Failed locking state for {}. Reason: '{}'", Pruner->GetGcName(Ctx), Ex.what()); } @@ -1563,7 +1563,7 @@ GcScheduler::AppendGCLog(GcClock::TimePoint StartTime, const GcSettings& Setting GcLogFile.Write(EntryBuffer, AppendPos); } } - catch (std::system_error& SystemError) + catch (const std::system_error& SystemError) { if (IsOOM(SystemError.code())) { @@ -1578,11 +1578,11 @@ GcScheduler::AppendGCLog(GcClock::TimePoint StartTime, const GcSettings& Setting ZEN_ERROR("writing gc result failed with system error exception: '{}'", SystemError.what()); } } - catch (std::bad_alloc& BadAlloc) + catch (const std::bad_alloc& BadAlloc) { ZEN_WARN("writing gc result ran out of memory: '{}'", BadAlloc.what()); } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_ERROR("writing gc result failed with: '{}'", Ex.what()); } @@ -1970,7 +1970,7 @@ GcScheduler::SchedulerThread() WaitTime = std::chrono::seconds(0); } - catch (std::system_error& SystemError) + catch (const std::system_error& SystemError) { if (IsOOM(SystemError.code())) { @@ -1988,14 +1988,14 @@ GcScheduler::SchedulerThread() m_LastLightweightGcTime = m_LastGcTime; WaitTime = m_Config.MonitorInterval; } - catch (std::bad_alloc& BadAlloc) + catch (const std::bad_alloc& BadAlloc) { ZEN_WARN("scheduling garbage collection ran out of memory: '{}'", BadAlloc.what()); m_LastGcTime = GcClock::Now(); m_LastLightweightGcTime = m_LastGcTime; WaitTime = m_Config.MonitorInterval; } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_ERROR("scheduling garbage collection failed with: '{}'", Ex.what()); m_LastGcTime = GcClock::Now(); @@ -2028,7 +2028,7 @@ GcScheduler::ScrubStorage(bool DoDelete, bool SkipCid, std::chrono::seconds Time Ctx.SetShouldDelete(DoDelete); m_GcManager.ScrubStorage(Ctx); } - catch (ScrubDeadlineExpiredException&) + catch (const ScrubDeadlineExpiredException&) { ZEN_INFO("scrubbing deadline expired (top level), operation incomplete!"); } @@ -2189,7 +2189,7 @@ GcScheduler::CollectGarbage(const GcClock::TimePoint& CacheExpireTime, SchedulerState << "LastGcExpireTime"sv << static_cast<int64_t>(m_LastGcExpireTime.time_since_epoch().count()); SaveCompactBinaryObject(Path, SchedulerState.Save()); } - catch (std::system_error& SystemError) + catch (const std::system_error& SystemError) { if (IsOOM(SystemError.code())) { @@ -2204,11 +2204,11 @@ GcScheduler::CollectGarbage(const GcClock::TimePoint& CacheExpireTime, ZEN_ERROR("writing gc scheduler state failed with system error exception: '{}'", SystemError.what()); } } - catch (std::bad_alloc& BadAlloc) + catch (const std::bad_alloc& BadAlloc) { ZEN_WARN("writing gc scheduler state ran out of memory: '{}'", BadAlloc.what()); } - catch (std::exception& Ex) + catch (const std::exception& Ex) { ZEN_ERROR("writing gc scheduler state failed with: '{}'", Ex.what()); } |