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

Valgrind memory leak fixes #43

Merged
merged 3 commits into from
Oct 15, 2018
Merged

Conversation

sanskriti-s
Copy link

Fixes valgrind warnings when running:

valgrind --leak-check=full --show-leak-kinds=all .libs/numademo -t -e 1M

@sanskriti-s sanskriti-s changed the title Valgrind Valgrind memory leak fixes Oct 9, 2018
@joe-lawrence
Copy link

"libnuma: cleanup nodemask in destructor"

  • I justed noticed closed issue Memory leak in libnuma.c: node_cpu_mask_v2 is never freed #3, though it seems trivial to clean up this data structure along with the bitmask pointers. Leave it up to the maintainer(s) whether to keep or drop this change from the series.
  • If we're gonna keep it, some small terminology / placement suggestions. The commit message, function name and code placement should be related to "cpu mask" and not "node mask". i.e.
    -- Rename numa_cleanup_nodemask to cleanup_node_cpu_mask_v2
    -- move cleanup_node_cpu_mask_v2() to just below its init_node_cpu_mask_v2() counterpart
    -- update commit msg accordingly

-- Joe

@andikleen
Copy link
Contributor

Can you remove the free() on error exits in numademo? That's too ugly. Freeing on normal exit is ok.
For the new clean up function in libnuma.c please follow the coding style: function prototype on single line, spaces around operators

Sanskriti Sharma added 3 commits October 10, 2018 14:24
Free node_cpu_mask_v2[] bitmap-pointer-array and all of the bitmaps
that it points to.

Fixes the following valgrind warnings:

  16 bytes in 1 blocks are still reachable in loss record 1 of 3
     at 0x4C28BE3: malloc (vg_replace_malloc.c:299)
     by 0x4E37E05: numa_bitmask_alloc (libnuma.c:210)
     by 0x4E3998E: numa_node_to_cpus@@libnuma_1.2 (libnuma.c:1381)
     by 0x4E3A3C9: numa_run_on_node (libnuma.c:1718)
     by 0x402DB5: test (in /home/sansharm/src/numactl/.libs/numademo)
     by 0x401672: main (in /home/sansharm/src/numactl/.libs/numademo)

  512 bytes in 1 blocks are still reachable in loss record 2 of 3
     at 0x4C2A975: calloc (vg_replace_malloc.c:711)
     by 0x4E37E24: numa_bitmask_alloc (libnuma.c:214)
     by 0x4E3998E: numa_node_to_cpus@@libnuma_1.2 (libnuma.c:1381)
     by 0x4E3A3C9: numa_run_on_node (libnuma.c:1718)
     by 0x402DB5: test (in /home/sansharm/src/numactl/.libs/numademo)
     by 0x401672: main (in /home/sansharm/src/numactl/.libs/numademo)

  8,192 bytes in 1 blocks are still reachable in loss record 3 of 3
     at 0x4C2A975: calloc (vg_replace_malloc.c:711)
     by 0x4E39974: init_node_cpu_mask_v2 (libnuma.c:1266)
     by 0x4E39974: numa_node_to_cpus@@libnuma_1.2 (libnuma.c:1361)
     by 0x4E3A3C9: numa_run_on_node (libnuma.c:1718)
     by 0x402DB5: test (in /home/sansharm/src/numactl/.libs/numademo)
     by 0x401672: main (in /home/sansharm/src/numactl/.libs/numademo)

Signed-off-by:Sanskriti Sharma <sansharm@redhat.com>
Free the test nodemasks after each test.

Fixes the following valgrind warnings:

  128 bytes in 1 blocks are indirectly lost in loss record 10 of 20
     at 0x4C2A975: calloc (vg_replace_malloc.c:711)
     by 0x4E37E84: numa_bitmask_alloc (libnuma.c:214)
     by 0x402CEB: test (in /home/sansharm/src/numactl/.libs/numademo)
     by 0x401661: main (in /home/sansharm/src/numactl/.libs/numademo)

  144 (16 direct, 128 indirect) bytes in 1 blocks are definitely lost in loss record 11 of 20
     at 0x4C28BE3: malloc (vg_replace_malloc.c:299)
     by 0x4E37E65: numa_bitmask_alloc (libnuma.c:210)
     by 0x402A07: test (in /home/sansharm/src/numactl/.libs/numademo)
     by 0x401612: main (in /home/sansharm/src/numactl/.libs/numademo)

Signed-off-by:Sanskriti Sharma <sansharm@redhat.com>
Frees pointer node_to_use before exiting program.

Fixes the following valgrind warnings:

  4 bytes in 1 blocks are still reachable in loss record 1 of 1
     at 0x4C28BE3: malloc (vg_replace_malloc.c:299)
     by 0x402973: get_node_list (in /home/sansharm/src/numactl/.libs/numademo)
     by 0x401450: main (in /home/sansharm/src/numactl/.libs/numademo)

Signed-off-by: Sanskriti Sharma <sansharm@redhat.com>
@sanskriti-s
Copy link
Author

v2:

  • "cpu node mask" renames (@joe-lawrence's)
  • dropped numademo error path frees (@andikleen)
  • libnuma style fixups: one line function prototype, spaces around
    operators in for() loop. (@andikleen)

@andikleen andikleen merged commit f567a26 into numactl:master Oct 15, 2018
@andikleen
Copy link
Contributor

Thanks!

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

3 participants