diff options
Diffstat (limited to 'indra')
-rwxr-xr-x | indra/llcommon/llthread.cpp | 7 | ||||
-rw-r--r-- | indra/llcommon/lltracerecording.cpp | 12 | ||||
-rw-r--r-- | indra/llcommon/lltracethreadrecorder.cpp | 30 |
3 files changed, 30 insertions, 19 deletions
diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index cf7768c67b..fd1f8ee096 100755 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -143,12 +143,13 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap //LL_INFOS() << "LLThread::staticRun() Exiting: " << threadp->mName << LL_ENDL; - // We're done with the run function, this thread is done executing now. - threadp->mStatus = STOPPED; - delete threadp->mRecorder; threadp->mRecorder = NULL; + // We're done with the run function, this thread is done executing now. + //NB: we are using this flag to sync across threads...we really need memory barriers here + threadp->mStatus = STOPPED; + return NULL; } diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index cd837c0867..d6232d771d 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -88,6 +88,9 @@ Recording::~Recording() disclaim_alloc(gTraceMemStat, this); disclaim_alloc(gTraceMemStat, mBuffers); + // allow recording destruction without thread recorder running, + // otherwise thread shutdown could crash if a recording outlives the thread recorder + // besides, recording construction and destruction is fine without a recorder...just don't attempt to start one if (isStarted() && LLTrace::get_thread_recorder().notNull()) { LLTrace::get_thread_recorder()->deactivate(mBuffers.write()); @@ -101,7 +104,10 @@ void Recording::update() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - llassert(mActiveBuffers); + // must have + llassert(mActiveBuffers != NULL + && LLTrace::get_thread_recorder().notNull()); + if(!mActiveBuffers->isCurrent()) { AccumulatorBufferGroup* buffers = mBuffers.write(); @@ -125,12 +131,16 @@ void Recording::handleStart() { mSamplingTimer.reset(); mBuffers.setStayUnique(true); + // must have thread recorder running on this thread + llassert(LLTrace::get_thread_recorder().notNull()); mActiveBuffers = LLTrace::get_thread_recorder()->activate(mBuffers.write()); } void Recording::handleStop() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); + // must have thread recorder running on this thread + llassert(LLTrace::get_thread_recorder().notNull()); LLTrace::get_thread_recorder()->deactivate(mBuffers.write()); mActiveBuffers = NULL; mBuffers.setStayUnique(false); diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index a14a8ff035..187d8546d3 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -191,25 +191,25 @@ ThreadRecorder::active_recording_list_t::iterator ThreadRecorder::bringUpToDate( void ThreadRecorder::deactivate( AccumulatorBufferGroup* recording ) { active_recording_list_t::iterator recording_it = bringUpToDate(recording); - if (recording_it != mActiveRecordings.end()) + // this method should only be called on a thread where the recorder is active + llassert_always(recording_it != mActiveRecordings.end()); + + ActiveRecording* recording_to_remove = *recording_it; + bool was_current = recording_to_remove->mPartialRecording.isCurrent(); + llassert(recording_to_remove->mTargetRecording == recording); + mActiveRecordings.erase(recording_it); + if (was_current) { - ActiveRecording* recording_to_remove = *recording_it; - bool was_current = recording_to_remove->mPartialRecording.isCurrent(); - llassert(recording_to_remove->mTargetRecording == recording); - mActiveRecordings.erase(recording_it); - if (was_current) + if (mActiveRecordings.empty()) { - if (mActiveRecordings.empty()) - { - AccumulatorBufferGroup::clearCurrent(); - } - else - { - mActiveRecordings.back()->mPartialRecording.makeCurrent(); - } + AccumulatorBufferGroup::clearCurrent(); + } + else + { + mActiveRecordings.back()->mPartialRecording.makeCurrent(); } - delete recording_to_remove; } + delete recording_to_remove; } ThreadRecorder::ActiveRecording::ActiveRecording( AccumulatorBufferGroup* target ) |