summaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_async.cpp
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2015-08-25 07:44:53 +0200
committerest31 <MTest31@outlook.com>2015-08-27 01:56:06 +0200
commit3304e1e517fb8aac008c4684e72a4b59b408414a (patch)
treeddcc820601c02d6783578b7accc68d35a2d312fc /src/script/cpp_api/s_async.cpp
parent8658c8d9b5f30dc952eed29a19d619de9210474c (diff)
downloadminetest-3304e1e517fb8aac008c4684e72a4b59b408414a.tar.gz
minetest-3304e1e517fb8aac008c4684e72a4b59b408414a.tar.bz2
minetest-3304e1e517fb8aac008c4684e72a4b59b408414a.zip
Push error handler afresh each time lua_pcall is used
Fixes "double fault" / "error in error handling" messages (issue #1423) and instead shows a complete backtrace.
Diffstat (limited to 'src/script/cpp_api/s_async.cpp')
-rw-r--r--src/script/cpp_api/s_async.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/script/cpp_api/s_async.cpp b/src/script/cpp_api/s_async.cpp
index 1e87e59f0..d18ff6e8c 100644
--- a/src/script/cpp_api/s_async.cpp
+++ b/src/script/cpp_api/s_async.cpp
@@ -144,8 +144,9 @@ void AsyncEngine::putJobResult(LuaJobInfo result)
}
/******************************************************************************/
-void AsyncEngine::step(lua_State *L, int errorhandler)
+void AsyncEngine::step(lua_State *L)
{
+ int error_handler = PUSH_ERROR_HANDLER(L);
lua_getglobal(L, "core");
resultQueueMutex.lock();
while (!resultQueue.empty()) {
@@ -164,10 +165,10 @@ void AsyncEngine::step(lua_State *L, int errorhandler)
lua_pushlstring(L, jobDone.serializedResult.data(),
jobDone.serializedResult.size());
- PCALL_RESL(L, lua_pcall(L, 2, 0, errorhandler));
+ PCALL_RESL(L, lua_pcall(L, 2, 0, error_handler));
}
resultQueueMutex.unlock();
- lua_pop(L, 1); // Pop core
+ lua_pop(L, 2); // Pop core and error handler
}
/******************************************************************************/
@@ -248,6 +249,8 @@ void* AsyncWorkerThread::run()
abort();
}
+ int error_handler = PUSH_ERROR_HANDLER(L);
+
lua_getglobal(L, "core");
if (lua_isnil(L, -1)) {
errorstream << "Unable to find core within async environment!";
@@ -279,7 +282,7 @@ void* AsyncWorkerThread::run()
toProcess.serializedParams.data(),
toProcess.serializedParams.size());
- int result = lua_pcall(L, 2, 1, m_errorhandler);
+ int result = lua_pcall(L, 2, 1, error_handler);
if (result) {
PCALL_RES(result);
toProcess.serializedResult = "";
@@ -296,7 +299,7 @@ void* AsyncWorkerThread::run()
jobDispatcher->putJobResult(toProcess);
}
- lua_pop(L, 1); // Pop core
+ lua_pop(L, 2); // Pop core and error handler
return 0;
}