#3591 rethrow should be mac specific
Jumped the gun a bit, since reportCrashToBugsplat is OS specific, restore rethrow for other systems.master
parent
a1ccb44c15
commit
ed394cd5a0
|
|
@ -228,6 +228,22 @@ std::string LLCoros::logname()
|
|||
return data.mName.empty()? data.getKey() : data.mName;
|
||||
}
|
||||
|
||||
void LLCoros::saveException(const std::string& name, std::exception_ptr exc)
|
||||
{
|
||||
mExceptionQueue.emplace(name, exc);
|
||||
}
|
||||
|
||||
void LLCoros::rethrow()
|
||||
{
|
||||
if (! mExceptionQueue.empty())
|
||||
{
|
||||
ExceptionData front = mExceptionQueue.front();
|
||||
mExceptionQueue.pop();
|
||||
LL_WARNS("LLCoros") << "Rethrowing exception from coroutine " << front.name << LL_ENDL;
|
||||
std::rethrow_exception(front.exception);
|
||||
}
|
||||
}
|
||||
|
||||
void LLCoros::setStackSize(S32 stacksize)
|
||||
{
|
||||
LL_DEBUGS("LLCoros") << "Setting coroutine stack size to " << stacksize << LL_ENDL;
|
||||
|
|
@ -370,7 +386,16 @@ void LLCoros::toplevel(std::string name, callable_t callable)
|
|||
// viewer will carry on.
|
||||
LOG_UNHANDLED_EXCEPTION(STRINGIZE("coroutine " << name));
|
||||
}
|
||||
// uncaught exception by default will cause std::terminate()
|
||||
#ifndef LL_WINDOWS
|
||||
catch (...)
|
||||
{
|
||||
// Stash any OTHER kind of uncaught exception in the rethrow() queue
|
||||
// to be rethrown by the main fiber.
|
||||
LL_WARNS("LLCoros") << "Capturing uncaught exception in coroutine "
|
||||
<< name << LL_ENDL;
|
||||
LLCoros::instance().saveException(name, std::current_exception());
|
||||
}
|
||||
#endif // ! LL_WINDOWS
|
||||
}
|
||||
|
||||
//static
|
||||
|
|
|
|||
|
|
@ -170,6 +170,19 @@ public:
|
|||
*/
|
||||
static std::string getName();
|
||||
|
||||
/**
|
||||
* rethrow() is called by the thread's main fiber to propagate an
|
||||
* exception from any coroutine into the main fiber, where it can engage
|
||||
* the normal unhandled-exception machinery, up to and including crash
|
||||
* reporting.
|
||||
*
|
||||
* LLCoros maintains a queue of otherwise-uncaught exceptions from
|
||||
* terminated coroutines. Each call to rethrow() pops the first of those
|
||||
* and rethrows it. When the queue is empty (normal case), rethrow() is a
|
||||
* no-op.
|
||||
*/
|
||||
void rethrow();
|
||||
|
||||
/**
|
||||
* This variation returns a name suitable for log messages: the explicit
|
||||
* name for an explicitly-launched coroutine, or "mainN" for the default
|
||||
|
|
@ -314,6 +327,20 @@ private:
|
|||
void toplevel(std::string name, callable_t callable);
|
||||
struct CoroData;
|
||||
static CoroData& get_CoroData(const std::string& caller);
|
||||
void saveException(const std::string& name, std::exception_ptr exc);
|
||||
|
||||
struct ExceptionData
|
||||
{
|
||||
ExceptionData(const std::string& nm, std::exception_ptr exc):
|
||||
name(nm),
|
||||
exception(exc)
|
||||
{}
|
||||
// name of coroutine that originally threw this exception
|
||||
std::string name;
|
||||
// the thrown exception
|
||||
std::exception_ptr exception;
|
||||
};
|
||||
std::queue<ExceptionData> mExceptionQueue;
|
||||
|
||||
S32 mStackSize;
|
||||
|
||||
|
|
|
|||
|
|
@ -1402,6 +1402,8 @@ bool LLAppViewer::doFrame()
|
|||
LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df suspend");
|
||||
// give listeners a chance to run
|
||||
llcoro::suspend();
|
||||
// if one of our coroutines threw an uncaught exception, rethrow it now
|
||||
LLCoros::instance().rethrow();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue