You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "Blake Bender (JIRA)" <ji...@apache.org> on 2019/03/08 18:48:00 UTC
[jira] [Created] (GEODE-6500)
apache::geode::client::InterestResultPolicy only works because we get lucky
Blake Bender created GEODE-6500:
-----------------------------------
Summary: apache::geode::client::InterestResultPolicy only works because we get lucky
Key: GEODE-6500
URL: https://issues.apache.org/jira/browse/GEODE-6500
Project: Geode
Issue Type: Bug
Components: native client
Reporter: Blake Bender
Here's the code in InterestResultPolicy.hpp:
{code:java}
namespace apache {
namespace geode {
namespace client {
/**
* @class InterestResultPolicy InterestResultPolicy.hpp
* Policy class for interest result.
*/
class APACHE_GEODE_EXPORT InterestResultPolicy {
// public static methods
public:
static char nextOrdinal;
static InterestResultPolicy NONE;
static InterestResultPolicy KEYS;
static InterestResultPolicy KEYS_VALUES;
char ordinal;
char getOrdinal() { return ordinal; }
private:
InterestResultPolicy() { ordinal = nextOrdinal++; }
};{code}
All the statics are initialized in InterestResultPolicy.cpp, with nextOrdinal set to 0. Thus, most of the time, the InterestResultPolicy instances NONE, KEYS, and KEYS_VALUES are assigned 1, 2, and 3, respectively. The Geode wire protocol most likely depends on these being fixed values, but the code as written relies on initialization order to get the correct values. Initialization order is *undefined behavior*, and compiler dependent. These need to be explicitly initialized, NONE KEYS and KEYS_VALUES should be members of an enum class rather than object instances, etc.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)