aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2022-01-14 16:17:19 -0800
committerbunnei <bunneidev@gmail.com>2022-01-14 16:17:19 -0800
commitf6de57c1a52b2170e820f092729e289a8d0ec0c0 (patch)
tree01f52e6791cdbb68cacdd1ffb5177db7f24b33fb
parentb2d45a4072cbce22eaba58700982306ba1a7e605 (diff)
common: fiber: YieldTo: Avoid hard crash on nullptr previous_fiber.
- When the emulator crashes to desktop below, we don't even get this captured in a log, making such issues harder to debug.
-rw-r--r--src/common/fiber.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/common/fiber.cpp b/src/common/fiber.cpp
index 62010d7625..81b212e4b8 100644
--- a/src/common/fiber.cpp
+++ b/src/common/fiber.cpp
@@ -124,7 +124,10 @@ void Fiber::YieldTo(std::weak_ptr<Fiber> weak_from, Fiber& to) {
// "from" might no longer be valid if the thread was killed
if (auto from = weak_from.lock()) {
- ASSERT(from->impl->previous_fiber != nullptr);
+ if (from->impl->previous_fiber == nullptr) {
+ ASSERT_MSG(false, "previous_fiber is nullptr!");
+ return;
+ }
from->impl->previous_fiber->impl->context = transfer.fctx;
from->impl->previous_fiber->impl->guard.unlock();
from->impl->previous_fiber.reset();