From 2a2edc1071f314f65fdd9c3bf8af888921c32830 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Fri, 3 May 2024 19:23:03 +0200 Subject: Fix handling of error occuring during lane setup --- src/lanes.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lanes.cpp b/src/lanes.cpp index 87edb02..e09956c 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp @@ -973,15 +973,19 @@ LUAG_FUNC(lane_new) ~OnExit() { if (m_lane) { + STACK_CHECK_START_REL(m_L, 0); // we still need a full userdata so that garbage collection can do its thing prepareUserData(); + // remove it immediately from the stack so that the error that landed us here is at the top + lua_pop(m_L, 1); + STACK_CHECK(m_L, 0); // leave a single cancel_error on the stack for the caller lua_settop(m_lane->L, 0); kCancelError.pushKey(m_lane->L); { std::lock_guard lock{ m_lane->doneMutex }; - m_lane->status = Lane::Cancelled; - m_lane->doneCondVar.notify_one(); // wake up master (while 'lane->doneMutex' is on) + // this will cause lane_main to skip actual running (because we are not Pending anymore) + m_lane->status = Lane::Running; } // unblock the thread so that it can terminate gracefully m_lane->ready.count_down(); -- cgit v1.2.3-55-g6feb