Closed rdw-software closed 10 months ago
Potential solutions:
os.exit
and make it perform the shutdown process automaticallyEdit: Option two would be easiest, but Lua can't access the loop structure (so it'd have to be done in the C++ layer).
Approach 2 does work, but it isn't pretty... Requires a number of convoluted jumping-through-hoops:
LuaVirtualMachine
must interface directly with the uws_ffi
bindings to unassign the looplightuserdata
), or the VM class itselfos.exit
function has to be implemented in C++, to replace (wrap) the original Lua oneThis adds a lot of complexity, relative to the actual usefulness of the code, and more stack manipulation than I prefer.
Potential improvements:
uws
package instead of a global UWS_EVENT_LOOP
os.exit
could be modified to just ignore the close
parameter and "ignore" the problem (sketchy)?Current prototype is here - will have to think about it some more as I'd prefer a simpler workaround if possible...
Actually, it doesn't look like the solution always works: In some cases (TBD) there are active handles still, but not sure why.
Can\t reliably reproduce, but there are handles being processed in luv (other than the ones spawned by uws) that may be the culprit. Unrelated? Let's see what the CI says, maybe the issues does crop up again, or perhaps it's a separate issue.
While investigating the ASAN warnings for #356 I came across this problem:
When calling
os.exit(code, true)
the Lua state will be closed immediately, without "unassigning" the loop held by uws (inmain.cpp
). The result is a SEGFAULT (at least with ASAN enabled), while not closing the state leaks memory in the test runner.