diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-10-22 20:12:36 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-10-22 21:50:26 +0200 |
commit | e2e9e617c634d143cd193c223ea5dd73570ade3c (patch) | |
tree | d4878156d1d414aecb000c770d77654c5bba2d33 /sc/inc/lookupcache.hxx | |
parent | c49d91805ec15668b2930c8657f1690e6391f701 (diff) |
Remove ScLookupCache from ScLookupCacheMap it had been added to
...instead of removing an arbitrary ScLookupCache with a matching ScRange from
the first ScLookupCacheMap that happens to contain one.
79449d73900d7a9bf061244d76f5f8eecc441198 "make VLOOKUP in Calc thread-safe"
introduced per-thread ScLookupCacheMaps, so that multiple ScLookupCacheMaps can
contain ScLookupCaches with identical ScRanges. For example, UITest_calc_tests6
adds ScLookupCaches for ScRange 1!R2C18:R97C18 to different threads'
ScLookupCacheMaps. That causes confusion so that calling
ScDocument::RemoveLookupCacheHelper to remove an ScLookupCache from a
mismatching ScLookupCacheMap accesses a different
ScLookupCache* pCache = (*it).second.release();
that may already have been destroyed; see failing ASan/UBSan builds like
<https://ci.libreoffice.org//job/lo_ubsan/1067/>.
Change-Id: I70c33b236dc502b8a98e0e313d422424eec5dbca
Reviewed-on: https://gerrit.libreoffice.org/62194
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sc/inc/lookupcache.hxx')
-rw-r--r-- | sc/inc/lookupcache.hxx | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sc/inc/lookupcache.hxx b/sc/inc/lookupcache.hxx index cca7a52ad38c..3a2be452a2ee 100644 --- a/sc/inc/lookupcache.hxx +++ b/sc/inc/lookupcache.hxx @@ -27,6 +27,7 @@ #include <unordered_map> class ScDocument; +struct ScLookupCacheMap; struct ScQueryEntry; /** Lookup cache for one range used with interpreter functions such as VLOOKUP @@ -106,7 +107,7 @@ public: }; /// MUST be new'd because Notify() deletes. - ScLookupCache( ScDocument * pDoc, const ScRange & rRange ); + ScLookupCache( ScDocument * pDoc, const ScRange & rRange, ScLookupCacheMap & cacheMap ); virtual ~ScLookupCache() override; /// Remove from document structure and delete (!) cache on modify hint. virtual void Notify( const SfxHint& rHint ) override; @@ -129,6 +130,8 @@ public: const ScRange& getRange() const { return maRange; } + ScLookupCacheMap & getCacheMap() const { return mCacheMap; } + struct Hash { size_t operator()( const ScRange & rRange ) const @@ -184,6 +187,7 @@ private: std::unordered_map< QueryKey, QueryCriteriaAndResult, QueryKey::Hash > maQueryMap; ScRange const maRange; ScDocument * mpDoc; + ScLookupCacheMap & mCacheMap; ScLookupCache( const ScLookupCache & ) = delete; ScLookupCache & operator=( const ScLookupCache & ) = delete; |