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

Memory leak (loop was never GCed) #379

Closed
vanc opened this issue Sep 20, 2019 · 1 comment · Fixed by #380
Closed

Memory leak (loop was never GCed) #379

vanc opened this issue Sep 20, 2019 · 1 comment · Fixed by #380

Comments

@vanc
Copy link

vanc commented Sep 20, 2019

Compiled luv.so with CLANG's address sanitizer, and run the unit tests, and found lots of leaks.

Troubleshooted a bit and found that the luv.c:loop_gc() was never triggered.

The issue seems started from revision db55f6b.

lua_pushstring(L, "_loop");
loop = (uv_loop_t*)lua_newuserdata(L, sizeof(*loop));
lua_rawset(L, -3);  // ref to loop, avoid __gc early

If remove the pushstring and rawset, loop_gc would be invoked too early, just as the comment says. However, with that, it was never called.

@zhaozg zhaozg added the bug label Sep 21, 2019
@squeek502
Copy link
Member

squeek502 commented Sep 21, 2019

Found the problem: uv_loop.meta is being set on the table returned from require (i.e. getmetatable(require('luv')).__gc), not the loop userdata. Will create a PR with the fix in a second.

Thanks for finding and reporting this @vanc ! If feasible, we should definitely try to include checks like this into our CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants