Skip to content

Instantly share code, notes, and snippets.

@jeffreylovitz
Last active December 17, 2019 16:14
Show Gist options
  • Save jeffreylovitz/10358a09341e1d0f8db3bbc11b5a82e1 to your computer and use it in GitHub Desktop.
Save jeffreylovitz/10358a09341e1d0f8db3bbc11b5a82e1 to your computer and use it in GitHub Desktop.
Valgrind report on multithreaded GraphBLAS
==7502== Memcheck, a memory error detector
==7502== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==7502== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==7502== Command: ./possible_leak
==7502==
==7502==
==7502== HEAP SUMMARY:
==7502== in use at exit: 5,680 bytes in 12 blocks
==7502== total heap usage: 27 allocs, 15 frees, 3,487,337 bytes allocated
==7502==
==7502== 8 bytes in 1 blocks are still reachable in loss record 1 of 6
==7502== at 0x4C2FDB3: malloc (vg_replace_malloc.c:309)
==7502== by 0x51E3A98: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x51F2A56: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x51E206A: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x4010732: call_init (dl-init.c:72)
==7502== by 0x4010732: _dl_init (dl-init.c:119)
==7502== by 0x40010C9: ??? (in /lib/x86_64-linux-gnu/ld-2.27.so)
==7502==
==7502== 72 bytes in 1 blocks are still reachable in loss record 2 of 6
==7502== at 0x4C2FCF4: malloc (vg_replace_malloc.c:308)
==7502== by 0x4C32243: realloc (vg_replace_malloc.c:836)
==7502== by 0x51E3AE8: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x51F180E: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x51E7EC9: GOMP_parallel (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x12B4D0: GB_nthreads (GB.h:920)
==7502== by 0x12B4D0: GB_resize (GB_resize.c:54)
==7502== by 0x12A330: GxB_Matrix_resize (GxB_Matrix_resize.c:31)
==7502== by 0x127082: main (possible_leak.c:19)
==7502==
==7502== 192 bytes in 1 blocks are still reachable in loss record 3 of 6
==7502== at 0x4C2FDB3: malloc (vg_replace_malloc.c:309)
==7502== by 0x51E3A98: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x51F0B45: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x51E7EB5: GOMP_parallel (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x12B4D0: GB_nthreads (GB.h:920)
==7502== by 0x12B4D0: GB_resize (GB_resize.c:54)
==7502== by 0x12A330: GxB_Matrix_resize (GxB_Matrix_resize.c:31)
==7502== by 0x127082: main (possible_leak.c:19)
==7502==
==7502== 208 bytes in 1 blocks are still reachable in loss record 4 of 6
==7502== at 0x4C2FDB3: malloc (vg_replace_malloc.c:309)
==7502== by 0x51E3A98: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x51F1FFA: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x51E3FDC: omp_set_nested (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x12AC3E: GB_init (GB_init.c:119)
==7502== by 0x129F2F: GrB_init (GrB_init.c:33)
==7502== by 0x126FF8: main (possible_leak.c:9)
==7502==
==7502== 2,128 bytes in 7 blocks are possibly lost in loss record 5 of 6
==7502== at 0x4C32002: calloc (vg_replace_malloc.c:762)
==7502== by 0x40134A6: allocate_dtv (dl-tls.c:286)
==7502== by 0x40134A6: _dl_allocate_tls (dl-tls.c:530)
==7502== by 0x5A06227: allocate_stack (allocatestack.c:627)
==7502== by 0x5A06227: pthread_create@@GLIBC_2.2.5 (pthread_create.c:644)
==7502== by 0x51F0F31: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x51E7EC9: GOMP_parallel (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x12B4D0: GB_nthreads (GB.h:920)
==7502== by 0x12B4D0: GB_resize (GB_resize.c:54)
==7502== by 0x12A330: GxB_Matrix_resize (GxB_Matrix_resize.c:31)
==7502== by 0x127082: main (possible_leak.c:19)
==7502==
==7502== 3,072 bytes in 1 blocks are still reachable in loss record 6 of 6
==7502== at 0x4C2FDB3: malloc (vg_replace_malloc.c:309)
==7502== by 0x51E3A98: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x51F09C7: ??? (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x51E7EB5: GOMP_parallel (in /usr/lib/x86_64-linux-gnu/libgomp.so.1.0.0)
==7502== by 0x12B4D0: GB_nthreads (GB.h:920)
==7502== by 0x12B4D0: GB_resize (GB_resize.c:54)
==7502== by 0x12A330: GxB_Matrix_resize (GxB_Matrix_resize.c:31)
==7502== by 0x127082: main (possible_leak.c:19)
==7502==
==7502== LEAK SUMMARY:
==7502== definitely lost: 0 bytes in 0 blocks
==7502== indirectly lost: 0 bytes in 0 blocks
==7502== possibly lost: 2,128 bytes in 7 blocks
==7502== still reachable: 3,552 bytes in 5 blocks
==7502== suppressed: 0 bytes in 0 blocks
==7502==
==7502== For lists of detected and suppressed errors, rerun with: -s
==7502== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
CFLAGS = -D_GNU_SOURCE -std=gnu99 -fopenmp -g
GRAPHBLAS=../deps/GraphBLAS/build/libgraphblas.a
all:
$(CC) $(CFLAGS) -o possible_leak possible_leak.c $(GRAPHBLAS) -lpthread -lm
clean:
rm possible_leak
#include <stdlib.h>
#include <assert.h>
#include "../deps/GraphBLAS/Include/GraphBLAS.h"
#include "../src/util/rmalloc.h"
#define DIMENSIONS 100000
int main() {
assert(GrB_init(GrB_NONBLOCKING) == GrB_SUCCESS);
GxB_set(GxB_FORMAT, GxB_BY_ROW); // all matrices in CSR format
GxB_set(GxB_HYPER, GxB_NEVER_HYPER); // matrices are never hypersparse
// Construct new matrix with default size
GrB_Matrix Adjacency;
GrB_Matrix_new(&Adjacency, GrB_BOOL, 16384, 16384);
// Resize to capacity on creation
GrB_Index new_cap = 114688; // computed matrix size during creation
assert(GxB_Matrix_resize(Adjacency, new_cap, new_cap) == GrB_SUCCESS);
GrB_Index nvals;
assert(GrB_Matrix_nvals(&nvals, Adjacency) == GrB_SUCCESS);
assert(GxB_Matrix_resize(Adjacency, DIMENSIONS, DIMENSIONS) == GrB_SUCCESS);
GrB_Matrix_free(&Adjacency);
GrB_finalize();
return 0;
}
@jeffreylovitz
Copy link
Author

Run with:
valgrind --leak-check=full --show-leak-kinds=all ./possible_leak

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