From 05dbd7dafe0e060e82aeedb5404101367bd4c622 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 2 Oct 2012 16:06:14 -0500 Subject: Instrument debug builds on windows to help track down source of heap corruption --- indra/llmessage/llcurl.cpp | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'indra/llmessage/llcurl.cpp') diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp index 5ea9b58300..0de47e0181 100644 --- a/indra/llmessage/llcurl.cpp +++ b/indra/llmessage/llcurl.cpp @@ -315,18 +315,23 @@ LLCurl::Easy* LLCurl::Easy::getEasy() LLCurl::Easy::~Easy() { + LL_CHECK_MEMORY releaseEasyHandle(mCurlEasyHandle); + LL_CHECK_MEMORY --gCurlEasyCount; curl_slist_free_all(mHeaders); + LL_CHECK_MEMORY for_each(mStrings.begin(), mStrings.end(), DeletePointerArray()); - + LL_CHECK_MEMORY if (mResponder && LLCurl::sNotQuitting) //aborted { std::string reason("Request timeout, aborted.") ; mResponder->completedRaw(408, //HTTP_REQUEST_TIME_OUT, timeout, abort reason, mChannels, mOutput); + LL_CHECK_MEMORY } mResponder = NULL; + LL_CHECK_MEMORY } void LLCurl::Easy::resetState() @@ -599,35 +604,49 @@ void LLCurl::Multi::cleanup(bool deleted) llassert_always(deleted || !mValid) ; LLMutexLock lock(mDeletionMutexp); - + + // Clean up active for(easy_active_list_t::iterator iter = mEasyActiveList.begin(); iter != mEasyActiveList.end(); ++iter) { Easy* easy = *iter; + LL_CHECK_MEMORY check_curl_multi_code(curl_multi_remove_handle(mCurlMultiHandle, easy->getCurlHandle())); - + LL_CHECK_MEMORY if(deleted) { easy->mResponder = NULL ; //avoid triggering mResponder. } delete easy; + LL_CHECK_MEMORY } mEasyActiveList.clear(); mEasyActiveMap.clear(); - // Clean up freed + LL_CHECK_MEMORY + + // Clean up freed for_each(mEasyFreeList.begin(), mEasyFreeList.end(), DeletePointer()); mEasyFreeList.clear(); - + + LL_CHECK_MEMORY + check_curl_multi_code(LLCurl::deleteMultiHandle(mCurlMultiHandle)); mCurlMultiHandle = NULL ; + + LL_CHECK_MEMORY delete mMutexp ; mMutexp = NULL ; + + LL_CHECK_MEMORY + delete mEasyMutexp ; mEasyMutexp = NULL ; + LL_CHECK_MEMORY + mQueued = 0 ; mState = STATE_COMPLETED; @@ -1504,29 +1523,42 @@ void LLCurl::cleanupClass() break ; } } + LL_CHECK_MEMORY sCurlThread->shutdown() ; + LL_CHECK_MEMORY delete sCurlThread ; sCurlThread = NULL ; + LL_CHECK_MEMORY #if SAFE_SSL CRYPTO_set_locking_callback(NULL); for_each(sSSLMutex.begin(), sSSLMutex.end(), DeletePointer()); #endif + + LL_CHECK_MEMORY for (std::set::iterator iter = Easy::sFreeHandles.begin(); iter != Easy::sFreeHandles.end(); ++iter) { CURL* curl = *iter; LLCurl::deleteEasyHandle(curl); } + + LL_CHECK_MEMORY Easy::sFreeHandles.clear(); + LL_CHECK_MEMORY + delete Easy::sHandleMutexp ; Easy::sHandleMutexp = NULL ; + LL_CHECK_MEMORY + delete sHandleMutexp ; sHandleMutexp = NULL ; + LL_CHECK_MEMORY + // removed as per https://jira.secondlife.com/browse/SH-3115 //llassert(Easy::sActiveHandles.empty()); } -- cgit v1.2.3 From 374f20edf09ff8194c715d190c114eaacac00bfe Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 3 Oct 2012 14:30:21 -0500 Subject: Fix non-thread-safe refcounting of LLHTTPClient::Responder and fix out-of-order deletion of LLTextureFetch on shutdown --- indra/llmessage/llcurl.cpp | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) (limited to 'indra/llmessage/llcurl.cpp') diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp index 0de47e0181..158e4ce091 100644 --- a/indra/llmessage/llcurl.cpp +++ b/indra/llmessage/llcurl.cpp @@ -133,12 +133,12 @@ std::string LLCurl::getVersionString() ////////////////////////////////////////////////////////////////////////////// LLCurl::Responder::Responder() - : mReferenceCount(0) { } LLCurl::Responder::~Responder() { + LL_CHECK_MEMORY } // virtual @@ -202,23 +202,6 @@ void LLCurl::Responder::completedHeader(U32 status, const std::string& reason, c } -namespace boost -{ - void intrusive_ptr_add_ref(LLCurl::Responder* p) - { - ++p->mReferenceCount; - } - - void intrusive_ptr_release(LLCurl::Responder* p) - { - if (p && 0 == --p->mReferenceCount) - { - delete p; - } - } -}; - - ////////////////////////////////////////////////////////////////////////////// std::set LLCurl::Easy::sFreeHandles; @@ -267,15 +250,18 @@ void LLCurl::Easy::releaseEasyHandle(CURL* handle) LLMutexLock lock(sHandleMutexp) ; if (sActiveHandles.find(handle) != sActiveHandles.end()) { + LL_CHECK_MEMORY sActiveHandles.erase(handle); - + LL_CHECK_MEMORY if(sFreeHandles.size() < MAX_NUM_FREE_HANDLES) { - sFreeHandles.insert(handle); - } - else - { + sFreeHandles.insert(handle); + LL_CHECK_MEMORY + } + else + { LLCurl::deleteEasyHandle(handle) ; + LL_CHECK_MEMORY } } else @@ -315,9 +301,7 @@ LLCurl::Easy* LLCurl::Easy::getEasy() LLCurl::Easy::~Easy() { - LL_CHECK_MEMORY releaseEasyHandle(mCurlEasyHandle); - LL_CHECK_MEMORY --gCurlEasyCount; curl_slist_free_all(mHeaders); LL_CHECK_MEMORY @@ -331,7 +315,6 @@ LLCurl::Easy::~Easy() LL_CHECK_MEMORY } mResponder = NULL; - LL_CHECK_MEMORY } void LLCurl::Easy::resetState() @@ -617,6 +600,7 @@ void LLCurl::Multi::cleanup(bool deleted) if(deleted) { easy->mResponder = NULL ; //avoid triggering mResponder. + LL_CHECK_MEMORY } delete easy; LL_CHECK_MEMORY @@ -1623,7 +1607,9 @@ void LLCurl::deleteEasyHandle(CURL* handle) if(handle) { LLMutexLock lock(sHandleMutexp) ; + LL_CHECK_MEMORY curl_easy_cleanup(handle) ; + LL_CHECK_MEMORY sTotalHandles-- ; } } -- cgit v1.2.3 From 827d8814cf1e6511333824273b624f0b814ce359 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 9 Oct 2012 13:34:28 -0500 Subject: MAINT-1688 Potential fix for crash on exit in LLTextureFetch --- indra/llmessage/llcurl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/llmessage/llcurl.cpp') diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp index 158e4ce091..10c83e6572 100644 --- a/indra/llmessage/llcurl.cpp +++ b/indra/llmessage/llcurl.cpp @@ -1104,6 +1104,7 @@ bool LLCurlRequest::getByteRange(const std::string& url, S32 offset, S32 length, LLCurl::ResponderPtr responder) { + llassert(LLCurl::sNotQuitting); LLCurl::Easy* easy = allocEasy(); if (!easy) { @@ -1126,6 +1127,7 @@ bool LLCurlRequest::post(const std::string& url, const LLSD& data, LLCurl::ResponderPtr responder, S32 time_out) { + llassert(LLCurl::sNotQuitting); LLCurl::Easy* easy = allocEasy(); if (!easy) { @@ -1153,6 +1155,7 @@ bool LLCurlRequest::post(const std::string& url, const std::string& data, LLCurl::ResponderPtr responder, S32 time_out) { + llassert(LLCurl::sNotQuitting); LLCurl::Easy* easy = allocEasy(); if (!easy) { @@ -1550,6 +1553,8 @@ void LLCurl::cleanupClass() //static CURLM* LLCurl::newMultiHandle() { + llassert(sNotQuitting); + LLMutexLock lock(sHandleMutexp) ; if(sTotalHandles + 1 > sMaxHandles) @@ -1583,6 +1588,7 @@ CURLMcode LLCurl::deleteMultiHandle(CURLM* handle) //static CURL* LLCurl::newEasyHandle() { + llassert(sNotQuitting); LLMutexLock lock(sHandleMutexp) ; if(sTotalHandles + 1 > sMaxHandles) -- cgit v1.2.3