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

libgearman serious memory leak #163

Open
sinkingsun2 opened this issue Aug 7, 2018 · 10 comments
Open

libgearman serious memory leak #163

sinkingsun2 opened this issue Aug 7, 2018 · 10 comments

Comments

@sinkingsun2
Copy link

I used naemon and mod_gearman/gearmand to check about 40k services. The memory usage on naemon process ramp up from 400M to 80G in 3 days. I used every thing latest gearmand-1.1.17 and mod_gearman-3.0.6 and naemon-1.0.8.
I used valgrind to pinpoint the leak to be in libgearman which the code is part of gearmand. naemon process will dynamic load mod_gearman which caused this serious leak.
I fixed the bug in gearmand-1.1.17/libgearman/add.cc line 325
free((void *)(task->send.data));
My C language knowledge still stays at 15 years ago, I may not have fixed it in the best way, so please fix it in the later release in the way you think is the best.

@esabol
Copy link
Member

esabol commented Aug 10, 2018

@sinkingsun2 Could you upload your valgrind logs and/or give instructions on how to reproduce? Thanks!

Also, the latest release is 1.1.18. Have you tried that?

@esabol
Copy link
Member

esabol commented Aug 10, 2018

You added that free before the if (gearman_success(rc)) {...}, right?

if (gearman_success(rc))

@esabol
Copy link
Member

esabol commented Aug 10, 2018

Also, what compiler (including the version number) are you using?

@sinkingsun2
Copy link
Author

sinkingsun2 commented Aug 10, 2018 via email

@sinkingsun2
Copy link
Author

sinkingsun2 commented Aug 10, 2018 via email

@sni
Copy link

sni commented Aug 10, 2018

This might be an issue in mod-gearman. We usually run Mod-Gearman with libgearman 0.35 and i didn't had the time to test any new releases successfully. So if something in the clients memory handling has to change, which isn't unlikely, then Mod-Gearman needs to be patched in order to run smoothly with recent libgearman versions.

@sinkingsun2
Copy link
Author

yeah, mod-gearman/naemon/gearmand, they invoke each other, it's hard to tell which caused the problem and where is the best place to fix it. but if you just download gearmand-1.1.17 and mod_gearman-3.0.6 and naemon-1.0.8, you should be able to reproduce the memory leak. In my case after I added that free code in add.cc, there is no leak anymore.

@esabol
Copy link
Member

esabol commented Sep 4, 2018

If anyone could reproduce this with just gearmand and some minimal clients and workers, we’d know for sure that the fix should be here in gearmand. As it is, it’s not clear, I think?

@SpamapS
Copy link
Member

SpamapS commented Sep 18, 2018

Hi! Please submit a PR with your fix. I know it's just a one-liner, but I'd like to have your name on the commits and your analysis in the commit message. Thanks so much for reporting the issue so we can get it fixed.

sinkingsun2 added a commit to sinkingsun2/gearmand that referenced this issue Sep 18, 2018
gearman#163
if anyone just check the code, task->send.data , that send.data should come from libgearman/packet.cc line 90:
packet->data= gearman_malloc(*packet->universal, arg_size);
( I am not 100% sure because it's been 20 days and I didn't log my analysis, I did my best to search code it looks familiar to me. )
and if you check where is the code to free packet->data , there is none.
that's why I just add a free here.
@sinkingsun2
Copy link
Author

sinkingsun2 commented Sep 18, 2018 via email

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

No branches or pull requests

5 participants