From d67c9a50560441d627171522da27aed281df1d00 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Wed, 21 Sep 2016 21:05:49 +0000 Subject: Ai, ai, ai. Here a nasty bug has been lurking... Accessing a moved/erase object.... --- .../vespa/vdslib/distribution/idealnodecalculatorcache.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'vdslib') diff --git a/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorcache.h b/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorcache.h index 54ffba869bd..22b1de941f5 100644 --- a/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorcache.h +++ b/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorcache.h @@ -44,20 +44,21 @@ class IdealNodeCalculatorCache : public IdealNodeCalculatorConfigurable { public: typedef vespalib::LinkedPtr LP; - TypeCache(const IdealNodeCalculator& c, const NodeType& t, - UpStates us, uint32_t size) + TypeCache(const IdealNodeCalculator& c, const NodeType& t, UpStates us, uint32_t size) : _calc(c), _nodeType(t), _upStates(us), _order(size, *this), - _hitCount(0), _missCount(0) {} + _hitCount(0), _missCount(0) + { } IdealNodeList get(const document::BucketId& bucket) { EntryMap::const_iterator it(_entries.find(bucket)); if (it == _entries.end()) { ++_missCount; Entry& newEntry(_entries[bucket]); - newEntry._result = _calc.getIdealNodes( - _nodeType, bucket, _upStates); - newEntry._order = _order.add(bucket); - return newEntry._result; + newEntry._result = _calc.getIdealNodes(_nodeType, bucket, _upStates); + LruOrder::EntryRef tmpOrder = _order.add(bucket); + Entry& movedEntry(_entries[bucket]); // The entry might very well move after the previous add. + movedEntry._order = tmpOrder; + return movedEntry._result; } else { ++_hitCount; _order.moveToStart(it->second._order); -- cgit v1.2.3