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

Add test to check if tox_new/tox_kill leaks. #341

Merged
merged 1 commit into from
Dec 20, 2016

Conversation

iphydf
Copy link
Member

@iphydf iphydf commented Dec 18, 2016

We create and destroy 20k tox instances and run a single tox_iterate on
it. This test is not comprehensive, but provides a simple check to see
whether the destruction properly cleans up memory and perhaps other
resources.


This change is Reviewable

@Ansa89
Copy link

Ansa89 commented Dec 20, 2016

Reviewed 1 of 2 files at r1.
Review status: 1 of 2 files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


auto_tests/resource_leak_test.c, line 3 at r1 (raw file):

#include "helpers.h"

#ifdef _BSD_SOURCE

According to man sbrk(2), this should be (on glibc >= 2.12):

_BSD_SOURCE || _SVID_SOURCE ||
                   (_XOPEN_SOURCE >= 500 ||
                       _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) &&
                   !(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)

Maybe you can check for those macros only one time and define a HAVE_SBRK 1 macro for later use.


auto_tests/resource_leak_test.c, line 23 at r1 (raw file):

    }

#if _BSD_SOURCE

Same as above, plus why not #ifdef?


auto_tests/resource_leak_test.c, line 25 at r1 (raw file):

#if _BSD_SOURCE
    // Low water mark.
    char *hwm = NULL;

Why not char *hwm = (char *)sbrk(0);?


Comments from Reviewable

@iphydf
Copy link
Member Author

iphydf commented Dec 20, 2016

Review status: 1 of 2 files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


auto_tests/resource_leak_test.c, line 3 at r1 (raw file):

Previously, Ansa89 wrote…

According to man sbrk(2), this should be (on glibc >= 2.12):

_BSD_SOURCE || _SVID_SOURCE ||
                   (_XOPEN_SOURCE >= 500 ||
                       _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) &&
                   !(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)

Maybe you can check for those macros only one time and define a HAVE_SBRK 1 macro for later use.

Done.


auto_tests/resource_leak_test.c, line 23 at r1 (raw file):

Previously, Ansa89 wrote…

Same as above, plus why not #ifdef?

Done.


auto_tests/resource_leak_test.c, line 25 at r1 (raw file):

Previously, Ansa89 wrote…

Why not char *hwm = (char *)sbrk(0);?

Historical reasons. Changed now.


Comments from Reviewable

@Ansa89
Copy link

Ansa89 commented Dec 20, 2016

Review status: 1 of 2 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


auto_tests/resource_leak_test.c, line 41 at r2 (raw file):

        tox_iterate(tox, NULL);
        tox_kill(tox);
#if _BSD_SOURCE

Change to #if HAVE_SBRK.


Comments from Reviewable

@iphydf
Copy link
Member Author

iphydf commented Dec 20, 2016

Review status: 1 of 2 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


auto_tests/resource_leak_test.c, line 41 at r2 (raw file):

Previously, Ansa89 wrote…

Change to #if HAVE_SBRK.

Done.


Comments from Reviewable

@Ansa89
Copy link

Ansa89 commented Dec 20, 2016

:lgtm_strong:


Reviewed 1 of 1 files at r3.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

We create and destroy 20k tox instances and run a single tox_iterate on
it. This test is not comprehensive, but provides a simple check to see
whether the destruction properly cleans up memory and perhaps other
resources.
@iphydf iphydf merged commit de623f9 into TokTok:master Dec 20, 2016
@iphydf iphydf deleted the resource-leak branch December 20, 2016 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants