Include backtrace in error message when LuaErrors occur
Tested in both Lua and LuaJIT by passing (NaN,NaN,NaN) to ObjectRef::setvelocity().
This commit is contained in:
parent
1fcea9112b
commit
deda3a9e44
@ -231,6 +231,11 @@ void ScriptApiBase::stackDump(std::ostream &o)
|
||||
o << std::endl;
|
||||
}
|
||||
|
||||
std::string ScriptApiBase::getBacktrace()
|
||||
{
|
||||
return script_get_backtrace(getStack());
|
||||
}
|
||||
|
||||
void ScriptApiBase::setOriginDirect(const char *origin)
|
||||
{
|
||||
m_last_run_mod = origin ? origin : "??";
|
||||
|
@ -75,6 +75,7 @@ public:
|
||||
void removeObjectReference(ServerActiveObject *cobj);
|
||||
|
||||
Server* getServer() { return m_server; }
|
||||
std::string getBacktrace();
|
||||
|
||||
std::string getOrigin() { return m_last_run_mod; }
|
||||
void setOriginDirect(const char *origin);
|
||||
|
@ -108,7 +108,14 @@ void *ServerThread::run()
|
||||
} catch (con::ConnectionBindFailed &e) {
|
||||
m_server->setAsyncFatalError(e.what());
|
||||
} catch (LuaError &e) {
|
||||
m_server->setAsyncFatalError("Lua: " + std::string(e.what()));
|
||||
std::ostringstream os(std::ios::binary);
|
||||
os<<"Lua: "<<e.what();
|
||||
std::string bt = m_server->getScriptBacktrace();
|
||||
if(!bt.empty())
|
||||
os<<std::endl<<bt;
|
||||
else
|
||||
os<<std::endl<<"No backtrace.";
|
||||
m_server->setAsyncFatalError(os.str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -3114,6 +3121,12 @@ Inventory* Server::createDetachedInventory(const std::string &name)
|
||||
return inv;
|
||||
}
|
||||
|
||||
std::string Server::getScriptBacktrace()
|
||||
{
|
||||
MutexAutoLock lock(m_env_mutex);
|
||||
return m_script->getBacktrace();
|
||||
}
|
||||
|
||||
// actions: time-reversed list
|
||||
// Return value: success/failure
|
||||
bool Server::rollbackRevertActions(const std::list<RollbackAction> &actions,
|
||||
|
@ -293,6 +293,8 @@ public:
|
||||
// Envlock and conlock should be locked when using scriptapi
|
||||
GameScripting *getScriptIface(){ return m_script; }
|
||||
|
||||
std::string getScriptBacktrace();
|
||||
|
||||
// actions: time-reversed list
|
||||
// Return value: success/failure
|
||||
bool rollbackRevertActions(const std::list<RollbackAction> &actions,
|
||||
|
Loading…
x
Reference in New Issue
Block a user