Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ASAN warnings due to (inconsequential) memory leaks in the main loop #359

Merged
merged 4 commits into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Runtime/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extern "C" {
#include "LuaVirtualMachine.hpp"

int main(int argc, char* argv[]) {
LuaVirtualMachine* luaVM = new LuaVirtualMachine();
std::unique_ptr<LuaVirtualMachine> luaVM = std::make_unique<LuaVirtualMachine>();

argv = uv_setup_args(argc, argv); // Required on Linux (see https://github.com/libuv/libuv/issues/2845)
luaVM->SetGlobalArgs(argc, argv);
Expand Down Expand Up @@ -51,14 +51,16 @@ int main(int argc, char* argv[]) {

// A bit of a hack; Can't use uv_default_loop because luv maintains a separate "default" loop of its own
uv_loop_t* loop = luv_loop(luaVM->GetState());
auto uwsEventLoop = uws_ffi::assignEventLoop(loop); // TBD: 5 handles created here...
auto uwsEventLoop = uws_ffi::assignEventLoop(loop);

std::string mainChunk = "local evo = require('evo'); return evo.run()";
std::string chunkName = "=(Lua entry point, at " FROM_HERE ")";

int success = luaVM->DoString(mainChunk, chunkName);
if(!success) {
std::cerr << "\t" << FROM_HERE << ": in function 'main'" << std::endl;

uws_ffi::unassignEventLoop(uwsEventLoop);
return EXIT_FAILURE;
}

Expand Down
Loading