From 189541d42c2eee8a624aa20942c72ceb60c0a0f6 Mon Sep 17 00:00:00 2001 From: "A.J. Beamon" Date: Thu, 20 Jun 2019 13:57:56 -0700 Subject: [PATCH 1/2] LoadBalancedReplies were sending uninitialized versions of their subclasses when there was an error. --- fdbclient/StorageServerInterface.h | 4 +++- fdbrpc/LoadBalance.actor.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fdbclient/StorageServerInterface.h b/fdbclient/StorageServerInterface.h index 6225fd50f7..9178720f4d 100644 --- a/fdbclient/StorageServerInterface.h +++ b/fdbclient/StorageServerInterface.h @@ -163,6 +163,8 @@ struct GetKeyValuesReply : public LoadBalancedReply { Version version; // useful when latestVersion was requested bool more; + GetKeyValuesReply() : version(invalidVersion), more(false) {} + template void serialize( Ar& ar ) { serializer(ar, *(LoadBalancedReply*)this, data, version, more, arena); @@ -190,7 +192,7 @@ struct GetKeyReply : public LoadBalancedReply { constexpr static FileIdentifier file_identifier = 11226513; KeySelector sel; - GetKeyReply() {} + GetKeyReply() : sel(KeySelectorRef(KeyRef(), false, 0)) {} GetKeyReply(KeySelector sel) : sel(sel) {} template diff --git a/fdbrpc/LoadBalance.actor.h b/fdbrpc/LoadBalance.actor.h index 557759d9a5..191b89d93f 100644 --- a/fdbrpc/LoadBalance.actor.h +++ b/fdbrpc/LoadBalance.actor.h @@ -65,6 +65,7 @@ struct ModelHolder : NonCopyable, public ReferenceCounted { } }; +// Subclasses must initialize all members in their default constructors struct LoadBalancedReply { double penalty; Optional error; From 1809b2e678d1e0cd9d39ce5f59f1fe6865215a0c Mon Sep 17 00:00:00 2001 From: "A.J. Beamon" Date: Thu, 20 Jun 2019 14:20:59 -0700 Subject: [PATCH 2/2] Initialize KeySelectorRef primitive types in its default constructor. --- fdbclient/FDBTypes.h | 2 +- fdbclient/StorageServerInterface.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fdbclient/FDBTypes.h b/fdbclient/FDBTypes.h index edb83f5f92..df1ace0089 100644 --- a/fdbclient/FDBTypes.h +++ b/fdbclient/FDBTypes.h @@ -401,7 +401,7 @@ private: public: bool orEqual; // (or equal to key, if this is true) int offset; // and then move forward this many items (or backward if negative) - KeySelectorRef() {} + KeySelectorRef() : orEqual(false), offset(0) {} KeySelectorRef( const KeyRef& key, bool orEqual, int offset ) : orEqual(orEqual), offset(offset) { setKey(key); } diff --git a/fdbclient/StorageServerInterface.h b/fdbclient/StorageServerInterface.h index 9178720f4d..51fccd9b87 100644 --- a/fdbclient/StorageServerInterface.h +++ b/fdbclient/StorageServerInterface.h @@ -192,7 +192,7 @@ struct GetKeyReply : public LoadBalancedReply { constexpr static FileIdentifier file_identifier = 11226513; KeySelector sel; - GetKeyReply() : sel(KeySelectorRef(KeyRef(), false, 0)) {} + GetKeyReply() {} GetKeyReply(KeySelector sel) : sel(sel) {} template