summaryrefslogtreecommitdiff
path: root/indra/llcommon/llcoros.cpp
diff options
context:
space:
mode:
authorBrad Kittenbrink <brad@lindenlab.com>2022-04-18 13:29:25 -0700
committerBrad Kittenbrink <brad@lindenlab.com>2022-04-18 13:29:25 -0700
commite9921e77b0a6c66855204db82d56de7925651a4d (patch)
tree510e353b4e773e18f95bd7312c813189f947dbb6 /indra/llcommon/llcoros.cpp
parentefb9df04c3899c269f0c17d2473b4472d5f31ee5 (diff)
parentd031662435d97101411ae990ed85d6e001ab668a (diff)
Merge remote-tracking branch 'origin/master' into DRTVWR-550-mfa
Diffstat (limited to 'indra/llcommon/llcoros.cpp')
-rw-r--r--indra/llcommon/llcoros.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/indra/llcommon/llcoros.cpp b/indra/llcommon/llcoros.cpp
index 75fc0fec99..c2d353b0fc 100644
--- a/indra/llcommon/llcoros.cpp
+++ b/indra/llcommon/llcoros.cpp
@@ -249,14 +249,25 @@ std::string LLCoros::launch(const std::string& prefix, const callable_t& callabl
// protected_fixedsize_stack sets a guard page past the end of the new
// stack so that stack underflow will result in an access violation
// instead of weird, subtle, possibly undiagnosed memory stomps.
- boost::fibers::fiber newCoro(boost::fibers::launch::dispatch,
- std::allocator_arg,
- boost::fibers::protected_fixedsize_stack(mStackSize),
- [this, &name, &callable](){ toplevel(name, callable); });
- // You have two choices with a fiber instance: you can join() it or you
- // can detach() it. If you try to destroy the instance before doing
- // either, the program silently terminates. We don't need this handle.
- newCoro.detach();
+
+ try
+ {
+ boost::fibers::fiber newCoro(boost::fibers::launch::dispatch,
+ std::allocator_arg,
+ boost::fibers::protected_fixedsize_stack(mStackSize),
+ [this, &name, &callable]() { toplevel(name, callable); });
+
+ // You have two choices with a fiber instance: you can join() it or you
+ // can detach() it. If you try to destroy the instance before doing
+ // either, the program silently terminates. We don't need this handle.
+ newCoro.detach();
+ }
+ catch (std::bad_alloc&)
+ {
+ // Out of memory on stack allocation?
+ LL_ERRS("LLCoros") << "Bad memory allocation in LLCoros::launch(" << prefix << ")!" << LL_ENDL;
+ }
+
return name;
}