From a6a2c8a80af57b99e08da36c4e64b0a0b868636f Mon Sep 17 00:00:00 2001 From: Nicholaz Beresford Date: Tue, 16 Sep 2008 02:08:45 -0500 Subject: Applied VWR-3878: Purging cache textures causes viewer to pause for many seconds, with heavy disk activity. --- ChangeLog.txt | 7 ++++ linden/indra/newview/lltexturecache.cpp | 65 ++++++++++++++++++++++++++++++--- linden/indra/newview/lltexturecache.h | 5 +++ 3 files changed, 71 insertions(+), 6 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index e69de29..da78f78 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -0,0 +1,7 @@ +2008-09-16 Nicholaz Beresford + + * linden/indra/newview/lltexturecache.cpp: + VWR-3878: Purging cache textures causes viewer to pause for many + seconds, with heavy disk activity. + * linden/indra/newview/lltexturecache.h: + Ditto. diff --git a/linden/indra/newview/lltexturecache.cpp b/linden/indra/newview/lltexturecache.cpp index 22cb6c1..0fbb3d9 100644 --- a/linden/indra/newview/lltexturecache.cpp +++ b/linden/indra/newview/lltexturecache.cpp @@ -881,6 +881,8 @@ LLTextureCache::LLTextureCache(bool threaded) LLTextureCache::~LLTextureCache() { + purgeTextureFilesTimeSliced(TRUE); // force-flush all pending file deletes + apr_pool_destroy(mFileAPRPool); } @@ -1187,7 +1189,7 @@ void LLTextureCache::purgeTextures(bool validate) return; } - LL_DEBUGS("TextureCache") << "TEXTURE CACHE: Reading Entries..." << LL_ENDL; + LL_DEBUGS("TextureCache") << "TEXTURE CACHE: Reading " << num_entries << " Entries from " << mTexturesDirEntriesFileName << LL_ENDL; std::map entry_idx_map; S64 total_size = 0; @@ -1216,7 +1218,7 @@ void LLTextureCache::purgeTextures(bool validate) LL_DEBUGS("TextureCache") << "TEXTURE CACHE: Validating: " << validate_idx << LL_ENDL; } - S64 min_cache_size = (sCacheMaxTexturesSize * 9) / 10; + S64 min_cache_size = sCacheMaxTexturesSize / 100 * 95; S32 purge_count = 0; S32 next_idx = 0; for (S32 idx=0; idx max_time_per_pass) + { + break; + } + } + + if (!mFilesToDelete.empty()) + { + llinfos << "TEXTURE CACHE: "<< howmany << " files deleted (" + << mFilesToDelete.size() << " files left for next pass)" + << llendl; + } + + mTimeLastFileDelete.reset(); +} + + + ////////////////////////////////////////////////////////////////////////////// // call lockWorkers() first! @@ -1462,6 +1511,10 @@ LLTextureCache::handle_t LLTextureCache::writeToCache(const LLUUID& id, U32 prio purgeTextures(false); mDoPurge = FALSE; } + + purgeTextureFilesTimeSliced(); // purge textures from cache in a non-hiccup-way + + if (datasize >= TEXTURE_CACHE_ENTRY_SIZE) { LLMutexLock lock(&mWorkersMutex); diff --git a/linden/indra/newview/lltexturecache.h b/linden/indra/newview/lltexturecache.h index f083dd0..e15a88b 100644 --- a/linden/indra/newview/lltexturecache.h +++ b/linden/indra/newview/lltexturecache.h @@ -119,6 +119,7 @@ private: void readHeaderCache(apr_pool_t* poolp = NULL); void purgeAllTextures(bool purge_directories); void purgeTextures(bool validate); + void purgeTextureFilesTimeSliced(BOOL force_all = FALSE); S32 getHeaderCacheEntry(const LLUUID& id, bool touch, S32* imagesize = NULL); bool removeHeaderCacheEntry(const LLUUID& id); void lockHeaders() { mHeaderMutex.lock(); } @@ -140,6 +141,10 @@ private: typedef std::vector, bool> > responder_list_t; responder_list_t mCompletedList; + + typedef std::list filename_list_t; + filename_list_t mFilesToDelete; + LLTimer mTimeLastFileDelete; BOOL mReadOnly; -- cgit v1.1 From d98f0844bd9d3dc6740d45960a65dd4e8f11e9ec Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Tue, 16 Sep 2008 12:20:16 -0500 Subject: Skip "N files scheduled for deletion" message when nothing scheduled. --- ChangeLog.txt | 5 +++++ linden/indra/newview/lltexturecache.cpp | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index da78f78..4b154b2 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,8 @@ +2008-09-16 Jacek Antonelli + + * linden/indra/newview/lltexturecache.cpp (purgeTextureFilesTimeSliced): + Skip "N files scheduled for deletion" message when nothing scheduled. + 2008-09-16 Nicholaz Beresford * linden/indra/newview/lltexturecache.cpp: diff --git a/linden/indra/newview/lltexturecache.cpp b/linden/indra/newview/lltexturecache.cpp index 0fbb3d9..ac956e2 100644 --- a/linden/indra/newview/lltexturecache.cpp +++ b/linden/indra/newview/lltexturecache.cpp @@ -1315,7 +1315,10 @@ void LLTextureCache::purgeTextureFilesTimeSliced(BOOL force_all) LLTimer timer; S32 howmany = 0; - llinfos << "TEXTURE CACHE: " << mFilesToDelete.size() << " files scheduled for deletion" << llendl; + if (mFilesToDelete.size() > 0) + { + llinfos << "TEXTURE CACHE: " << mFilesToDelete.size() << " files scheduled for deletion" << llendl; + } for (LLTextureCache::filename_list_t::iterator iter = mFilesToDelete.begin(); iter!=mFilesToDelete.end(); ) { -- cgit v1.1 From 5c920015e999cfe9860e769105632891db3e1916 Mon Sep 17 00:00:00 2001 From: Nicholaz Beresford Date: Wed, 17 Sep 2008 01:49:35 -0500 Subject: VWR-2003: Possible crash in lltooldraganddrop.cpp. --- ChangeLog.txt | 4 ++++ linden/indra/newview/lltooldraganddrop.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index e69de29..376a749 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -0,0 +1,4 @@ +2008-09-17 Nicholaz Beresford + + * linden/indra/newview/lltooldraganddrop.cpp (dragOrDrop): + VWR-2003: Possible crash in lltooldraganddrop.cpp. diff --git a/linden/indra/newview/lltooldraganddrop.cpp b/linden/indra/newview/lltooldraganddrop.cpp index c492c7b..7a378a9 100644 --- a/linden/indra/newview/lltooldraganddrop.cpp +++ b/linden/indra/newview/lltooldraganddrop.cpp @@ -929,6 +929,12 @@ void LLToolDragAndDrop::dragOrDrop( S32 x, S32 y, MASK mask, BOOL drop, { LLInventoryObject* cargo = locateInventory(item, cat); + if (!cargo) + { + handled = FALSE; + break; + } + EAcceptance item_acceptance = ACCEPT_NO; handled = handled && root_view->handleDragAndDrop(x, y, mask, FALSE, mCargoTypes[mCurItemIndex], -- cgit v1.1 From 36e67d5a189529f14ffde674da9ea24bdccd3023 Mon Sep 17 00:00:00 2001 From: Nicholaz Beresford Date: Wed, 17 Sep 2008 02:09:44 -0500 Subject: VWR-2685: Possible crash in bounding box (getBoundingBoxAgent()) from hud attachments. --- ChangeLog.txt | 5 +++++ linden/indra/newview/llviewerjointattachment.h | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index e69de29..2cc6cca 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -0,0 +1,5 @@ +2008-09-17 Nicholaz Beresford + + * linden/indra/newview/llviewerjointattachment.h (LLViewerJoint): + VWR-2685: Possible crash in bounding box (getBoundingBoxAgent()) + from hud attachments. diff --git a/linden/indra/newview/llviewerjointattachment.h b/linden/indra/newview/llviewerjointattachment.h index 8e665aa..a69c10c 100644 --- a/linden/indra/newview/llviewerjointattachment.h +++ b/linden/indra/newview/llviewerjointattachment.h @@ -98,8 +98,7 @@ protected: void calcLOD(); protected: - // Backlink only; don't make this an LLPointer. - LLViewerObject* mAttachedObject; + LLPointer mAttachedObject; BOOL mVisibleInFirst; LLVector3 mOriginalPos; S32 mGroup; -- cgit v1.1 From bd0eb5fde3c408c6e66a80101c38edd605528380 Mon Sep 17 00:00:00 2001 From: Nicholaz Beresford Date: Wed, 17 Sep 2008 02:16:50 -0500 Subject: VWR-2683: Possible crash accessing dead llviewerregion. --- ChangeLog.txt | 6 ++++++ linden/indra/newview/llfloateractivespeakers.cpp | 4 ++-- linden/indra/newview/llviewerobjectlist.cpp | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index e69de29..36a5be0 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -0,0 +1,6 @@ +2008-09-17 Nicholaz Beresford + + * linden/indra/newview/llfloateractivespeakers.cpp (updateSpeakerList): + VWR-2683: Possible crash accessing dead llviewerregion. + * linden/indra/newview/llviewerobjectlist.cpp (killObjects): + Ditto. diff --git a/linden/indra/newview/llfloateractivespeakers.cpp b/linden/indra/newview/llfloateractivespeakers.cpp index ed2f9f8..9aa21d5 100644 --- a/linden/indra/newview/llfloateractivespeakers.cpp +++ b/linden/indra/newview/llfloateractivespeakers.cpp @@ -1342,7 +1342,7 @@ void LLLocalSpeakerMgr::updateSpeakerList() for(avatar_it = LLCharacter::sInstances.begin(); avatar_it != LLCharacter::sInstances.end(); ++avatar_it) { LLVOAvatar* avatarp = (LLVOAvatar*)*avatar_it; - if (dist_vec(avatarp->getPositionAgent(), gAgent.getPositionAgent()) <= CHAT_NORMAL_RADIUS) + if (!avatarp->isDead() && dist_vec(avatarp->getPositionAgent(), gAgent.getPositionAgent()) <= CHAT_NORMAL_RADIUS) { setSpeaker(avatarp->getID()); } @@ -1356,7 +1356,7 @@ void LLLocalSpeakerMgr::updateSpeakerList() if (speakerp->mStatus == LLSpeaker::STATUS_TEXT_ONLY) { LLVOAvatar* avatarp = (LLVOAvatar*)gObjectList.findObject(speaker_id); - if (!avatarp || dist_vec(avatarp->getPositionAgent(), gAgent.getPositionAgent()) > CHAT_NORMAL_RADIUS) + if (!avatarp || avatarp->isDead() || dist_vec(avatarp->getPositionAgent(), gAgent.getPositionAgent()) > CHAT_NORMAL_RADIUS) { speakerp->mStatus = LLSpeaker::STATUS_NOT_IN_CHANNEL; speakerp->mDotColor = INACTIVE_COLOR; diff --git a/linden/indra/newview/llviewerobjectlist.cpp b/linden/indra/newview/llviewerobjectlist.cpp index bd8ed97..dec7ced 100644 --- a/linden/indra/newview/llviewerobjectlist.cpp +++ b/linden/indra/newview/llviewerobjectlist.cpp @@ -859,6 +859,10 @@ void LLViewerObjectList::killObjects(LLViewerRegion *regionp) if (objectp->mRegionp == regionp) { killObject(objectp); + + // invalidate region pointer. region will become invalid, but + // refcounted objects may survive the cleanDeadObjects() call below + objectp->mRegionp = NULL; } } -- cgit v1.1 From 5c59f5fdb33b70d032e1b6578c9fb583b97070ca Mon Sep 17 00:00:00 2001 From: Nicholaz Beresford Date: Tue, 16 Sep 2008 21:49:15 -0500 Subject: VWR-3877: A nasty possible memory overwrite and two minor leaks. --- ChangeLog.txt | 4 +++ linden/indra/llmessage/llassetstorage.cpp | 41 ++++++++++++++++--------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index e69de29..e06910f 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -0,0 +1,4 @@ +2008-09-16 Nicholaz Beresford + + * linden/indra/llmessage/llassetstorage.cpp: + VWR-3877: A nasty possible memory overwrite and two minor leaks. diff --git a/linden/indra/llmessage/llassetstorage.cpp b/linden/indra/llmessage/llassetstorage.cpp index a6077e5..83026ba 100644 --- a/linden/indra/llmessage/llassetstorage.cpp +++ b/linden/indra/llmessage/llassetstorage.cpp @@ -515,16 +515,19 @@ void LLAssetStorage::downloadCompleteCallback( S32 result, const LLUUID& file_id, LLAssetType::EType file_type, - void* user_data, LLExtStat ext_status) + void* callback_parm_req, LLExtStat ext_status) { lldebugs << "LLAssetStorage::downloadCompleteCallback() for " << file_id << "," << LLAssetType::lookup(file_type) << llendl; - LLAssetRequest* req = (LLAssetRequest*)user_data; + + // be careful! req may be a ptr to memory already freed (a timeout does this) + LLAssetRequest* req = (LLAssetRequest*)callback_parm_req; if(!req) { llwarns << "LLAssetStorage::downloadCompleteCallback called without" "a valid request." << llendl; - return; + // we can live with a null pointer, we're not allowed to deref the ptr anyway (see above) + // return; } if (!gAssetStorage) { @@ -532,12 +535,10 @@ void LLAssetStorage::downloadCompleteCallback( return; } - req->setUUID(file_id); - req->setType(file_type); if (LL_ERR_NOERR == result) { // we might have gotten a zero-size file - LLVFile vfile(gAssetStorage->mVFS, req->getUUID(), req->getType()); + LLVFile vfile(gAssetStorage->mVFS, file_id, file_type); if (vfile.getSize() <= 0) { llwarns << "downloadCompleteCallback has non-existent or zero-size asset " << req->getUUID() << llendl; @@ -556,7 +557,7 @@ void LLAssetStorage::downloadCompleteCallback( { request_list_t::iterator curiter = iter++; LLAssetRequest* tmp = *curiter; - if ((tmp->getUUID() == req->getUUID()) && (tmp->getType()== req->getType())) + if ((tmp->getUUID() == file_id) && (tmp->getType() == file_type)) { requests.push_front(tmp); iter = gAssetStorage->mPendingDownloads.erase(curiter); @@ -569,7 +570,7 @@ void LLAssetStorage::downloadCompleteCallback( LLAssetRequest* tmp = *curiter; if (tmp->mDownCallback) { - tmp->mDownCallback(gAssetStorage->mVFS, req->getUUID(), req->getType(), tmp->mUserData, result, ext_status); + tmp->mDownCallback(gAssetStorage->mVFS, tmp->getUUID(), tmp->getType(), tmp->mUserData, result, ext_status); } delete tmp; } @@ -665,10 +666,10 @@ void LLAssetStorage::downloadEstateAssetCompleteCallback( S32 result, const LLUUID& file_id, LLAssetType::EType file_type, - void* user_data, + void* callback_parm_req, LLExtStat ext_status) { - LLEstateAssetRequest *req = (LLEstateAssetRequest*)user_data; + LLEstateAssetRequest *req = (LLEstateAssetRequest*)callback_parm_req; if(!req) { llwarns << "LLAssetStorage::downloadEstateAssetCompleteCallback called" @@ -682,12 +683,10 @@ void LLAssetStorage::downloadEstateAssetCompleteCallback( return; } - req->setUUID(file_id); - req->setType(file_type); if (LL_ERR_NOERR == result) { // we might have gotten a zero-size file - LLVFile vfile(gAssetStorage->mVFS, req->getUUID(), req->getAType()); + LLVFile vfile(gAssetStorage->mVFS, file_id, file_type); if (vfile.getSize() <= 0) { llwarns << "downloadCompleteCallback has non-existent or zero-size asset!" << llendl; @@ -697,7 +696,9 @@ void LLAssetStorage::downloadEstateAssetCompleteCallback( } } - req->mDownCallback(gAssetStorage->mVFS, req->getUUID(), req->getAType(), req->mUserData, result, ext_status); + req->mDownCallback(gAssetStorage->mVFS, file_id, file_type, req->mUserData, result, ext_status); + + delete req; } void LLAssetStorage::getInvItemAsset(const LLHost &object_sim, const LLUUID &agent_id, const LLUUID &session_id, @@ -802,10 +803,10 @@ void LLAssetStorage::downloadInvItemCompleteCallback( S32 result, const LLUUID& file_id, LLAssetType::EType file_type, - void* user_data, + void* callback_parm_req, LLExtStat ext_status) { - LLInvItemRequest *req = (LLInvItemRequest*)user_data; + LLInvItemRequest *req = (LLInvItemRequest*)callback_parm_req; if(!req) { llwarns << "LLAssetStorage::downloadEstateAssetCompleteCallback called" @@ -818,12 +819,10 @@ void LLAssetStorage::downloadInvItemCompleteCallback( return; } - req->setUUID(file_id); - req->setType(file_type); if (LL_ERR_NOERR == result) { // we might have gotten a zero-size file - LLVFile vfile(gAssetStorage->mVFS, req->getUUID(), req->getType()); + LLVFile vfile(gAssetStorage->mVFS, file_id, file_type); if (vfile.getSize() <= 0) { llwarns << "downloadCompleteCallback has non-existent or zero-size asset!" << llendl; @@ -833,7 +832,9 @@ void LLAssetStorage::downloadInvItemCompleteCallback( } } - req->mDownCallback(gAssetStorage->mVFS, req->getUUID(), req->getType(), req->mUserData, result, ext_status); + req->mDownCallback(gAssetStorage->mVFS, file_id, file_type, req->mUserData, result, ext_status); + + delete req; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.1