From 236593e997e931580d3bd3192b12e450c8054b07 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 11 Feb 2022 20:26:00 +0200 Subject: Revert "SL-14961 Coroutine crash was not reported to bugsplat" Will be replaced with retrow from nat --- indra/llcommon/llcoros.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/llcoros.h') diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index a94cfca19f..51f7380def 100644 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -292,12 +292,11 @@ public: private: std::string generateDistinctName(const std::string& prefix) const; -#if LL_WINDOWS - void winlevel(const std::string& name, const callable_t& callable); -#endif - void toplevelTryWrapper(const std::string& name, const callable_t& callable); void toplevel(std::string name, callable_t callable); struct CoroData; +#if LL_WINDOWS + static void winlevel(const callable_t& callable); +#endif static CoroData& get_CoroData(const std::string& caller); S32 mStackSize; -- cgit v1.2.3 From 6c3507d6d358485c2a8e2fc4d915847cbeda3ee3 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Sun, 16 Dec 2018 14:31:32 -0500 Subject: SL-10190: Introduce LLCoros::saveException() and rethrow(). This mechanism uses a queue of std::exception_ptrs to transport an (otherwise) uncaught exception from a terminated coroutine to the thread's main fiber. The main loop calls LLCoros::rethrow() just after giving some cycles to ready coroutines that frame. # Conflicts: # indra/llcommon/llcoros.cpp # indra/llcommon/llcoros.h # indra/newview/llappviewer.cpp --- indra/llcommon/llcoros.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'indra/llcommon/llcoros.h') diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index 51f7380def..59b2b91f96 100644 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -38,6 +38,8 @@ #include "llinstancetracker.h" #include #include +#include +#include // e.g. #include LLCOROS_MUTEX_HEADER #define LLCOROS_MUTEX_HEADER @@ -156,6 +158,19 @@ public: * LLCoros::launch()). */ 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 @@ -298,6 +313,20 @@ private: static void winlevel(const callable_t& callable); #endif 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 mExceptionQueue; S32 mStackSize; -- cgit v1.2.3 From 913bddf18fa33b54cdb6e30ebd290363e33e7f47 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Sun, 16 Dec 2018 14:51:39 -0500 Subject: SL-10190: Slightly reduce conditional clutter in llcoros.{h,cpp}. Rename 'winlevel()' to 'sehandle()'; change it from a static member function to a free function, thus eliminating the conditional in llcoros.h. Elsewhere than Windows, provide a zero-cost pass-through sehandle() implementation, eliminating the conditional in toplevel(). # Conflicts: # indra/llcommon/llcoros.cpp # indra/llcommon/llcoros.h --- indra/llcommon/llcoros.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/llcommon/llcoros.h') diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index 59b2b91f96..966ce03296 100644 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -309,9 +309,6 @@ private: std::string generateDistinctName(const std::string& prefix) const; void toplevel(std::string name, callable_t callable); struct CoroData; -#if LL_WINDOWS - static void winlevel(const callable_t& callable); -#endif static CoroData& get_CoroData(const std::string& caller); void saveException(const std::string& name, std::exception_ptr exc); -- cgit v1.2.3 From 935c1362a222f192bf913270d01f6c31c16e175b Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 14 Feb 2022 22:26:43 +0200 Subject: Restored SL-14961 SL-14961 works better for windows than rethrow --- indra/llcommon/llcoros.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/llcommon/llcoros.h') diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index 966ce03296..dbff921f16 100644 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -307,7 +307,11 @@ public: private: std::string generateDistinctName(const std::string& prefix) const; - void toplevel(std::string name, callable_t callable); + void toplevelTryWrapper(const std::string& name, const callable_t& callable); +#if LL_WINDOWS + void sehHandle(const std::string& name, const callable_t& callable); // calls toplevelTryWrapper +#endif + void toplevel(std::string name, callable_t callable); // calls sehHandle or toplevelTryWrapper struct CoroData; static CoroData& get_CoroData(const std::string& caller); void saveException(const std::string& name, std::exception_ptr exc); -- cgit v1.2.3