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

memleak hook: find leaks in plugins #4737

Merged
merged 20 commits into from
Sep 8, 2021

Conversation

rustyrussell
Copy link
Contributor

@rustyrussell rustyrussell commented Aug 23, 2021

And indeed, it found some. None as major as the one in #4721 but that seems to be when the plugin doesn't read the entire JSON stream at once, and leaks the command struct, which doesn't happen in our tests (at least here).

This is based on #4754 thanks to @cdecker suggesting a generic shutdown notification!

@rustyrussell
Copy link
Contributor Author

rustyrussell commented Aug 23, 2021

Trivial fix for non-DEVELOPER unit test builds, and rebase to fix trivial conflict on master.

@rustyrussell rustyrussell marked this pull request as ready for review August 25, 2021 02:32
@cdecker
Copy link
Member

cdecker commented Aug 30, 2021

Just a minor comment about the DEVELOPER flag being implicitly forced onto plugins that may have been compiled in another environment.

plugins/libplugin.c Outdated Show resolved Hide resolved
plugins/libplugin.c Show resolved Hide resolved
Copy link
Member

@cdecker cdecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK c8f4d31

@@ -1182,8 +1182,7 @@ static void PRINTF_FMT(1,2) log_memleak(const char *fmt, ...)
va_list ap;

va_start(ap, fmt);
/* FIXME: This is LOG_DEBUG until we fix leaks! */
plugin_logv(memleak_plugin, LOG_DEBUG, fmt, ap);
plugin_logv(memleak_plugin, LOG_BROKEN, fmt, ap);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, this is why the shutdown isn't a hook.

@cdecker
Copy link
Member

cdecker commented Sep 4, 2021

Reasing to address conflict in test_gossip.py

@cdecker
Copy link
Member

cdecker commented Sep 5, 2021

Had a minor fixup to apply: plugin_exit in DEVELOPER=1 mode was missing the plugin argument.

@cdecker
Copy link
Member

cdecker commented Sep 5, 2021

Unused variable in DEVELOPER=0, added more compile guards to drop has_shutdown_notif completely in that config.

This is useful for plugins which can't send junk to stdout.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This will let plugins use it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Otherwise the NULL parents look like a memleak.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…pics.

Useful for plugins which dynamically generate them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
mar
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
And free the err string when policy turns out not to be a u64.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
They get grafted into clone, so have them parented there.  Otherwise
we get a small leak every time we RBF.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Otherwise it looks like a leak.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This lets memleak track them, but makes sure they don't leak; using
notleak could cover up a leak here.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
And fix utx leak in the withdraw case.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Another tiny leak, which happened in keysend which uses these routines.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…mmer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Plugins: C plugins would could leak memory on every command (esp. seen when hammering topology's listchannels).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Now we've fixed them, this makes sure CI notices if new leaks appear.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@rustyrussell rustyrussell force-pushed the guilt/memleak-hook branch 2 times, most recently from f830bca to f4f0527 Compare September 8, 2021 00:06
Otherwise we get very upset when the plugins go away.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@cdecker
Copy link
Member

cdecker commented Sep 8, 2021

ACK 9315cee

@cdecker cdecker merged commit ad31a49 into ElementsProject:master Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants