diff options
author | David Madl <git@abanbytes.eu> | 2016-03-21 21:35:12 +0300 |
---|---|---|
committer | David Madl <git@abanbytes.eu> | 2016-03-22 12:37:30 +0300 |
commit | b760ad8a7edbe253a9b366f088d51919a1eb67a5 (patch) | |
tree | 88f132f3e19283dc716ce4941a98ac53e12e728b /moses/FeatureVector.cpp | |
parent | 000de1c1dd6db871afdc60618db7d9c77dc31704 (diff) |
BUGFIX: fix ScoreComponentCollection::ZeroAll(), affecting MIRA
I observed a bug that ScoreComponentCollection core entries would retain their score even after ZeroAll(). This may have affected the Moses implementation of MIRA.
* std::valarray::resize(0) means "resize to 0" [1]
* subsequent accesses using operator[] result in undefined behavior [2]
FeatureVector::clear() is used by ScoreComponentCollection::ZeroAll(), which in turn was used in these places:
./contrib/mira/Main.cpp:665: cumulativeWeights.ZeroAll();
./contrib/mira/Main.cpp:666: cumulativeWeightsBinary.ZeroAll();
./moses/Incremental.cpp:580: features.ZeroAll();
It seems to me that the Moses implementation of MIRA may have been affected?
[1] http://www.cplusplus.com/reference/valarray/valarray/resize/
[2] http://www.cplusplus.com/reference/valarray/valarray/operator%5B%5D/
Diffstat (limited to 'moses/FeatureVector.cpp')
-rw-r--r-- | moses/FeatureVector.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/moses/FeatureVector.cpp b/moses/FeatureVector.cpp index 45a198c84..f92bcedae 100644 --- a/moses/FeatureVector.cpp +++ b/moses/FeatureVector.cpp @@ -175,7 +175,7 @@ void FVector::resize(size_t newsize) void FVector::clear() { - m_coreFeatures.resize(0); + m_coreFeatures.resize(m_coreFeatures.size(), 0); m_features.clear(); } |