From a5d6c9687519e23ac39e041efd745ec8bcb072b9 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Sat, 16 Jan 2021 01:04:28 +0000 Subject: [PATCH 1/2] Fix heap use after free See https://github.com/apple/foundationdb/blob/master/flow/README.md#arenas for an explanation of how *Ref types are supposed to work --- fdbserver/storageserver.actor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 3b771bf3a8..2ef506b69e 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -316,7 +316,7 @@ public: class CurrentRunningFetchKeys { std::unordered_map startTimeMap; - std::unordered_map keyRangeMap; + std::unordered_map keyRangeMap; static const StringRef emptyString; static const KeyRangeRef emptyKeyRange; @@ -331,7 +331,7 @@ public: keyRangeMap.erase(id); } - std::pair longestTime() const { + std::pair longestTime() const { if (numRunning() == 0) { return {-1, emptyKeyRange}; } From 45f064c420e267a3ab284173a41d7ac197244eba Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Tue, 19 Jan 2021 16:49:48 +0000 Subject: [PATCH 2/2] Take keyRange by const reference --- fdbserver/storageserver.actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index 2ef506b69e..467decfd58 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -321,7 +321,7 @@ public: static const StringRef emptyString; static const KeyRangeRef emptyKeyRange; public: - void recordStart(const UID id, const KeyRange keyRange) { + void recordStart(const UID id, const KeyRange& keyRange) { startTimeMap[id] = now(); keyRangeMap[id] = keyRange; }