#3591 Restructure SE to not catch LLContinueError

It was reporting shutdown as crashes to bugsplat
master
Andrey Kleshchev 2025-03-12 16:03:37 +02:00 committed by Andrey Kleshchev
parent b50ad90feb
commit 7e9e5bf872
1 changed files with 31 additions and 15 deletions

View File

@ -331,11 +331,33 @@ U32 exception_filter(U32 code, struct _EXCEPTION_POINTERS* exception_infop)
return EXCEPTION_CONTINUE_SEARCH;
}
void sehandle(const LLCoros::callable_t& callable)
void cpphandle(const LLCoros::callable_t& callable, const std::string& name)
{
// SE and C++ can not coexists, thus two handlers
try
{
callable();
}
catch (const LLCoros::Stop& exc)
{
LL_INFOS("LLCoros") << "coroutine " << name << " terminating because "
<< exc.what() << LL_ENDL;
}
catch (const LLContinueError&)
{
// Any uncaught exception derived from LLContinueError will be caught
// here and logged. This coroutine will terminate but the rest of the
// viewer will carry on.
LOG_UNHANDLED_EXCEPTION(STRINGIZE("coroutine " << name));
}
}
void sehandle(const LLCoros::callable_t& callable, const std::string& name)
{
__try
{
callable();
// handle stop and continue exceptions first
cpphandle(callable, name);
}
__except (exception_filter(GetExceptionCode(), GetExceptionInformation()))
{
@ -347,16 +369,7 @@ void sehandle(const LLCoros::callable_t& callable)
throw std::exception(integer_string);
}
}
#else // ! LL_WINDOWS
inline void sehandle(const LLCoros::callable_t& callable)
{
callable();
}
#endif // ! LL_WINDOWS
#endif // LL_WINDOWS
} // anonymous namespace
// Top-level wrapper around caller's coroutine callable.
@ -369,10 +382,14 @@ void LLCoros::toplevel(std::string name, callable_t callable)
// set it as current
mCurrent.reset(&corodata);
#ifdef LL_WINDOWS
// can not use __try directly, toplevel requires unwinding, thus use of a wrapper
sehandle(callable, name);
#else // LL_WINDOWS
// run the code the caller actually wants in the coroutine
try
{
sehandle(callable);
callable();
}
catch (const Stop& exc)
{
@ -386,7 +403,6 @@ void LLCoros::toplevel(std::string name, callable_t callable)
// viewer will carry on.
LOG_UNHANDLED_EXCEPTION(STRINGIZE("coroutine " << name));
}
#ifndef LL_WINDOWS
catch (...)
{
// Stash any OTHER kind of uncaught exception in the rethrow() queue
@ -395,7 +411,7 @@ void LLCoros::toplevel(std::string name, callable_t callable)
<< name << LL_ENDL;
LLCoros::instance().saveException(name, std::current_exception());
}
#endif // ! LL_WINDOWS
#endif // else LL_WINDOWS
}
//static