mirror of https://github.com/bjornbytes/lovr.git
Stack trace when background thread crashes
Without this, the error handler only prints the _main thread's error handler's_ stack trace
This commit is contained in:
parent
e8db2f8187
commit
453d348fdc
|
@ -23,12 +23,15 @@ static int threadRunner(void* data) {
|
||||||
luax_register(L, lovrModules);
|
luax_register(L, lovrModules);
|
||||||
lua_pop(L, 2);
|
lua_pop(L, 2);
|
||||||
|
|
||||||
|
lua_pushcfunction(L, luax_getstack);
|
||||||
|
int errhandler = lua_gettop(L);
|
||||||
|
|
||||||
if (!luaL_loadbuffer(L, thread->body->data, thread->body->size, "thread")) {
|
if (!luaL_loadbuffer(L, thread->body->data, thread->body->size, "thread")) {
|
||||||
for (uint32_t i = 0; i < thread->argumentCount; i++) {
|
for (uint32_t i = 0; i < thread->argumentCount; i++) {
|
||||||
luax_pushvariant(L, &thread->arguments[i]);
|
luax_pushvariant(L, &thread->arguments[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lua_pcall(L, thread->argumentCount, 0, 0)) {
|
if (!lua_pcall(L, thread->argumentCount, 0, errhandler)) {
|
||||||
mtx_lock(&thread->lock);
|
mtx_lock(&thread->lock);
|
||||||
thread->running = false;
|
thread->running = false;
|
||||||
mtx_unlock(&thread->lock);
|
mtx_unlock(&thread->lock);
|
||||||
|
|
Loading…
Reference in New Issue