Open xrobau opened 10 years ago
Most of these look like issues with your system libraries? The last one is expected: we knowingly leak parsed config files since we borrow strings from within them.
Having a quick look at the first ones, curl, you're doing this:
if (curl_easy_perform(curl)) {... stuff ... curl_easy_cleanup(curl); }
You're not doing a cleanup if it fails. That's the first leak, I guess?
The only instance of that is in setup_stratum_curl, where the curl needs to remain on success (in pool->stratum_curl). It might help if you dump leaks before exiting, since it's pretty likely things get leaked when we're shutting down (pthread_cancel etc).
Add to your ~/.gdbinit
define valgrind-get-leaks
set pagination off
target remote | vgdb $arg0
monitor leak_check full any unlimited
detach
quit
end
Then you can run gdb and use valgrind-get-leaks --pid=<pid>
of a running valgrind instance to get leaks without exiting
I noticed that the latest BFGminer crashed earlier this morning, so I ran it through valgrind to see if there's any errors, and there's a couple.
$ ./configure --without--libusb --without-uio --without-vfio --disable-avalon --disable-modminer --disable-bitforce --disable-antminer --disable-bifury --disable-bigpic --disable-bitfury_gpio --disable-cairnsmore --disable-drillbit --disable-dualminer --disable-hashfast --disable-icarus --disable-littlefury --disable-twinfury --disable-bitfury --disable-avalonmm --disable-rockminer
Running on a 64bit RHEL 6 machine, with everything disabled -apart- from stratum proxy. (Is there any easier way to say 'only enable proxy'? I can't seem to --enable it so --disable-others works..)
This is after only running for a few minutes
==10980== ==10980== HEAP SUMMARY: ==10980== in use at exit: 953,126 bytes in 1,414 blocks ==10980== total heap usage: 5,644,849 allocs, 5,643,435 frees, 482,574,880 bytes allocated ==10980== ==10980== 40 bytes in 1 blocks are possibly lost in loss record 103 of 282 ==10980== at 0x4C279EE: malloc (vg_replace_malloc.c:270) ==10980== by 0x875356B: ??? (in /lib64/libnspr4.so) ==10980== by 0x876ADF4: ??? (in /lib64/libnspr4.so) ==10980== by 0x876C000: PR_Socket (in /lib64/libnspr4.so) ==10980== by 0x4E6FA3E: ??? (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E67734: Curl_ssl_connect (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E4618A: Curl_http_connect (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E4C921: Curl_protocol_connect (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E52DBB: Curl_connect (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E5AE2F: Curl_perform (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4413C4: setup_stratum_curl (util.c:2914) ==10980== by 0x4417DA: initiate_stratum (util.c:3003) ==10980== ==10980== 48 bytes in 1 blocks are possibly lost in loss record 111 of 282 ==10980== at 0x4C279EE: malloc (vg_replace_malloc.c:270) ==10980== by 0x8753559: ??? (in /lib64/libnspr4.so) ==10980== by 0x876ADF4: ??? (in /lib64/libnspr4.so) ==10980== by 0x876C000: PR_Socket (in /lib64/libnspr4.so) ==10980== by 0x4E6FA3E: ??? (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E67734: Curl_ssl_connect (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E4618A: Curl_http_connect (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E4C921: Curl_protocol_connect (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E52DBB: Curl_connect (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E5AE2F: Curl_perform (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4413C4: setup_stratum_curl (util.c:2914) ==10980== by 0x4417DA: initiate_stratum (util.c:3003) ==10980== ==10980== 80 bytes in 2 blocks are possibly lost in loss record 140 of 282 ==10980== at 0x4C279EE: malloc (vg_replace_malloc.c:270) ==10980== by 0x875356B: ??? (in /lib64/libnspr4.so) ==10980== by 0x876ADF4: ??? (in /lib64/libnspr4.so) ==10980== by 0x876AF71: PR_ImportTCPSocket (in /lib64/libnspr4.so) ==10980== by 0x4E7031C: ??? (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E67734: Curl_ssl_connect (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E4618A: Curl_http_connect (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E4C921: Curl_protocol_connect (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E52DBB: Curl_connect (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E5AE2F: Curl_perform (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4413C4: setup_stratum_curl (util.c:2914) ==10980== by 0x4417DA: initiate_stratum (util.c:3003) ==10980== ==10980== 96 bytes in 2 blocks are possibly lost in loss record 141 of 282 ==10980== at 0x4C279EE: malloc (vg_replace_malloc.c:270) ==10980== by 0x8753559: ??? (in /lib64/libnspr4.so) ==10980== by 0x876ADF4: ??? (in /lib64/libnspr4.so) ==10980== by 0x876AF71: PR_ImportTCPSocket (in /lib64/libnspr4.so) ==10980== by 0x4E7031C: ??? (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E67734: Curl_ssl_connect (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E4618A: Curl_http_connect (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E4C921: Curl_protocol_connect (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E52DBB: Curl_connect (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4E5AE2F: Curl_perform (in /usr/lib64/libcurl.so.4.1.1) ==10980== by 0x4413C4: setup_stratum_curl (util.c:2914) ==10980== by 0x4417DA: initiate_stratum (util.c:3003) ==10980== ==10980== 304 bytes in 1 blocks are possibly lost in loss record 197 of 282 ==10980== at 0x4C2677B: calloc (vg_replace_malloc.c:593) ==10980== by 0x40118A2: _dl_allocate_tls (in /lib64/ld-2.12.so) ==10980== by 0x52951E8: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.12.so) ==10980== by 0x457247: stratumsrv_start (driver-stratum.c:730) ==10980== by 0x432CA8: main (miner.c:12680) ==10980== by 0x40118A2: _dl_allocate_tls (in /lib64/ld-2.12.so) ==10980== by 0x52951E8: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.12.so) ==10980== by 0x457247: stratumsrv_start (driver-stratum.c:730) ==10980== by 0x432CA8: main (miner.c:12680) ==10980== ==10980== 304 bytes in 1 blocks are possibly lost in loss record 198 of 282 ==10980== at 0x4C2677B: calloc (vg_replace_malloc.c:593) ==10980== by 0x40118A2: _dl_allocate_tls (in /lib64/ld-2.12.so) ==10980== by 0x52951E8: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.12.so) ==10980== by 0x43BDA8: thr_info_create (util.c:983) ==10980== by 0x432CF6: main (miner.c:12694) ==10980== ==10980== 304 bytes in 1 blocks are possibly lost in loss record 199 of 282 ==10980== at 0x4C2677B: calloc (vg_replace_malloc.c:593) ==10980== by 0x40118A2: _dl_allocate_tls (in /lib64/ld-2.12.so) ==10980== by 0x52951E8: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.12.so) ==10980== by 0x44F8AF: proxy_first_client (driver-proxy.c:76) ==10980== by 0x450B45: proxy_find_or_create_client (driver-proxy.c:123) ==10980== by 0x455794: _stratumsrv_find_or_create_client (driver-stratum.c:334) ==10980== by 0x455BCB: stratumsrv_mining_authorize (driver-stratum.c:415) ==10980== by 0x456B4A: stratumsrv_process_line (driver-stratum.c:574) ==10980== by 0x456DEA: stratumsrv_read (driver-stratum.c:614) ==10980== by 0x6199EE4: bufferevent_readcb (bufferevent_sock.c:186) ==10980== by 0x6191E0B: event_base_loop (event.c:1350) ==10980== by 0x457211: stratumsrv_thread (driver-stratum.c:721) ==10980== ==10980== 608 bytes in 2 blocks are possibly lost in loss record 227 of 282 ==10980== at 0x4C2677B: calloc (vg_replace_malloc.c:593) ==10980== by 0x40118A2: _dl_allocate_tls (in /lib64/ld-2.12.so) ==10980== by 0x52951E8: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.12.so) ==10980== by 0x42FF94: probe_pools (miner.c:12057) ==10980== by 0x432597: main (miner.c:12547) ==10980== ==10980== 608 bytes in 2 blocks are possibly lost in loss record 228 of 282 ==10980== at 0x4C2677B: calloc (vg_replace_malloc.c:593) ==10980== by 0x40118A2: _dl_allocate_tls (in /lib64/ld-2.12.so) ==10980== by 0x52951E8: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.12.so) ==10980== by 0x424321: init_stratum_thread (miner.c:8786) ==10980== by 0x424967: pool_active (miner.c:8920) ==10980== by 0x42C5CF: test_pool_thread (miner.c:10897) ==10980== by 0x52959D0: start_thread (in /lib64/libpthread-2.12.so) ==10980== by 0x64ADB5C: clone (in /lib64/libc-2.12.so) ==10980== ==10980== 4,138 (72 direct, 4,066 indirect) bytes in 1 blocks are definitely lost in loss record 270 of 282 ==10980== at 0x4C279EE: malloc (vg_replace_malloc.c:270) ==10980== by 0x508A33A: json_object (value.c:41) ==10980== by 0x5087174: parse_value (load.c:673) ==10980== by 0x5087584: parse_json (load.c:860) ==10980== by 0x5087793: json_loadf (load.c:992) ==10980== by 0x5087835: json_load_file (load.c:1018) ==10980== by 0x40BC49: load_config (miner.c:2556) ==10980== by 0x40BD83: _load_default_configs (miner.c:2583) ==10980== by 0x43E028: _appdata_file_call (util.c:1956) ==10980== by 0x43E15F: appdata_file_call (util.c:1990) ==10980== by 0x40BDB4: load_default_config (miner.c:2592) ==10980== by 0x43151E: main (miner.c:12279) ==10980== ==10980== LEAK SUMMARY: ==10980== definitely lost: 72 bytes in 1 blocks ==10980== indirectly lost: 4,066 bytes in 88 blocks ==10980== possibly lost: 2,392 bytes in 13 blocks ==10980== still reachable: 946,596 bytes in 1,312 blocks ==10980== suppressed: 0 bytes in 0 blocks ==10980== Reachable blocks (those to which a pointer was found) are not shown. ==10980== To see them, rerun with: --leak-check=full --show-reachable=yes ==10980== ==10980== For counts of detected and suppressed errors, rerun with: -v ==10980== ERROR SUMMARY: 10 errors from 10 contexts (suppressed: 12 from 9)