diff options
| author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2025-04-16 22:48:25 +0300 | 
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2025-04-17 16:01:12 +0300 | 
| commit | 2e4d2ddae15428002d289ea6d097cc3300d16559 (patch) | |
| tree | b49e61d4f2d1b8a79b95d049efd61750e5d71c23 | |
| parent | 67921fae6d9f32464b42b6b3086de109c0761532 (diff) | |
#3627 Crash on texture cache init
I'm not sure if I should be crashing and logging this data to bugsplat
or if I should let it be in case cache file is unreasonably big.
| -rw-r--r-- | indra/newview/lltexturecache.cpp | 44 | 
1 files changed, 28 insertions, 16 deletions
| diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index be7653c011..442c627d07 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -1347,27 +1347,39 @@ U32 LLTextureCache::openAndReadEntries(std::vector<Entry>& entries)      }      for (U32 idx=0; idx<num_entries; idx++)      { -        Entry entry; -        S32 bytes_read = aprfile->read((void*)(&entry), (S32)sizeof(Entry)); -        if (bytes_read < sizeof(Entry)) +        try +        { +            Entry entry; +            S32 bytes_read = aprfile->read((void*)(&entry), (S32)sizeof(Entry)); +            if (bytes_read < sizeof(Entry)) +            { +                LL_WARNS() << "Corrupted header entries, failed at " << idx << " / " << num_entries << LL_ENDL; +                return 0; +            } +            entries.push_back(entry); +            //      LL_INFOS() << "ENTRY: " << entry.mTime << " TEX: " << entry.mID << " IDX: " << idx << " Size: " << entry.mImageSize << LL_ENDL; +            if (entry.mImageSize > entry.mBodySize) +            { +                mHeaderIDMap[entry.mID] = idx; +                mTexturesSizeMap[entry.mID] = entry.mBodySize; +                mTexturesSizeTotal += entry.mBodySize; +            } +            else +            { +                mFreeList.insert(idx); +            } +        } +        catch (std::bad_alloc&)          { -            LL_WARNS() << "Corrupted header entries, failed at " << idx << " / " << num_entries << LL_ENDL; +            // Too little ram yet very large cache? +            // Should this actually crash viewer? +            entries.clear(); +            LL_WARNS() << "Bad alloc trying to read texture entries from cache, mFreeList: " << (S32)mFreeList.size() +                << ", added entries: " << idx << ", total entries: " << num_entries << LL_ENDL;              closeHeaderEntriesFile();              purgeAllTextures(false);              return 0;          } -        entries.push_back(entry); -//      LL_INFOS() << "ENTRY: " << entry.mTime << " TEX: " << entry.mID << " IDX: " << idx << " Size: " << entry.mImageSize << LL_ENDL; -        if(entry.mImageSize > entry.mBodySize) -        { -            mHeaderIDMap[entry.mID] = idx; -            mTexturesSizeMap[entry.mID] = entry.mBodySize; -            mTexturesSizeTotal += entry.mBodySize; -        } -        else -        { -            mFreeList.insert(idx); -        }      }      closeHeaderEntriesFile();      return num_entries; | 
