aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-09-30 15:31:52 +0200
committerGitHub <[email protected]>2022-09-30 06:31:52 -0700
commitc25e128f3a9ff395263f3d107cbb6f059cda67d2 (patch)
tree5ca4f2e21512acf97232558b943adac51a3b4970
parentDe/reduce buffer creation in parsepackedmessage (#175) (diff)
downloadzen-c25e128f3a9ff395263f3d107cbb6f059cda67d2.tar.xz
zen-c25e128f3a9ff395263f3d107cbb6f059cda67d2.zip
Handle zero size file mapping (#177)
* Handle edgecase with zero size memory mapping of file * changelog
-rw-r--r--CHANGELOG.md4
-rw-r--r--zencore/iobuffer.cpp11
2 files changed, 13 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 33dd37e08..6b1d170c8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,9 @@
- Change: All RPC responses are now formatted using dedicated wire format, Zen server has fallback to enable compatability with legacy upstreams
- Feature: Adding a `.json` extension to the `--abslog` option will make zenserver log in json format to file
- Feature: Create release in Sentry and use `sentry_options_set_release` to associate the executable
-- Bugfix: CompactBinary: Fixed LoadCompactBinary to gracefully handle read failures and sizes larger than the archive. From https://p4-swarm.epicgames.net/changes/21983905
+- Bugfix: CompactBinary: Fixed LoadCompactBinary to gracefully handle read failures and sizes larger than the archive. From http1s://p4-swarm.epicgames.net/changes/21983905
+- Bugfix: Use bucket/key to get inline value in upstream for chunks without a chunkid
+- Bugfix: Handle edge case when trying to materialize a IoBuffer of zero size via memory mapping
- Improvement: Logging: don't do formatting of messages the will not be logged
- Improvement: Logging: Timing and upstream source information in upstream logging when debug level logging is enabled
- Improvement: Reduce buffer creation and copying in ParsePackageMessage
diff --git a/zencore/iobuffer.cpp b/zencore/iobuffer.cpp
index 37ef57c2d..177b7dfb6 100644
--- a/zencore/iobuffer.cpp
+++ b/zencore/iobuffer.cpp
@@ -267,9 +267,18 @@ IoBufferExtendedCore::Materialize() const
if (m_Flags.load(std::memory_order_relaxed) & kIsMaterialized)
return;
- void* NewMmapHandle;
uint32_t NewFlags = kIsMaterialized;
+ if (m_DataBytes == 0)
+ {
+ m_Flags.fetch_or(NewFlags, std::memory_order_release);
+ // Fake a "valid" pointer, nobody should read this as size is zero
+ m_DataPtr = reinterpret_cast<uint8_t*>(&m_MmapHandle);
+ return;
+ }
+
+ void* NewMmapHandle;
+
const uint64_t MapOffset = m_FileOffset & ~0xffffull;
const uint64_t MappedOffsetDisplacement = m_FileOffset - MapOffset;
const uint64_t MapSize = m_DataBytes + MappedOffsetDisplacement;