Dear libcurl mailing list readers, I'm working on a little c++ wrapper for libcurl which resembles a lot the python2 module mechanize.Browser() Here is the link to the library: https://github.com/venam/Browser It really makes some tasks look relatively easy compared to the libcurl or curlpp way of doing. However, I'm not sure about how I managed to not leak memory. I tried to put in all the destructors the "free" functions but running valgrind with --leak-check=yes shows me that there's some bytes that are leaked during the process.I'm not an expert in debugging but I see that some leaks are from libcrypto.
If someone could clear my mind about that or just lead me to a better way to do things. (This email is linked with the valgrind logs.) Thank you for your prompt support, Patrick Louis -- _Patrick Louis_
==10840== Memcheck, a memory error detector ==10840== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. ==10840== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info ==10840== Command: ./mechanize ==10840== Parent PID: 10630 ==10840== --10840-- --10840-- Valgrind options: --10840-- --log-file=logs --10840-- --leak-check=yes --10840-- -v --10840-- Contents of /proc/version: --10840-- Linux version 3.7.6-VENAM (raptor@venam) (gcc version 4.7.2 (GCC) ) #1 SMP PREEMPT Wed Feb 6 15:09:02 EET 2013 --10840-- Arch and hwcaps: X86, x86-sse1-sse2 --10840-- Page sizes: currently 4096, max supported 4096 --10840-- Valgrind library directory: /usr/lib/valgrind --10840-- Reading syms from /usr/lib/ld-2.17.so --10840-- Reading syms from /home/raptor/mechanize_plus_plus/mechanize/bin/Debug/mechanize --10840-- object doesn't have a symbol table --10840-- Reading syms from /usr/lib/valgrind/memcheck-x86-linux --10840-- object doesn't have a symbol table --10840-- object doesn't have a dynamic symbol table --10840-- Scheduler: using generic scheduler lock implementation. --10840-- Reading suppressions file: /usr/lib/valgrind/default.supp ==10840== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-10840-by-raptor-on-??? ==10840== embedded gdbserver: writing to /tmp/vgdb-pipe-to-vgdb-from-10840-by-raptor-on-??? ==10840== embedded gdbserver: shared mem /tmp/vgdb-pipe-shared-mem-vgdb-10840-by-raptor-on-??? ==10840== ==10840== TO CONTROL THIS PROCESS USING vgdb (which you probably ==10840== don't want to do, unless you know exactly what you're doing, ==10840== or are doing some strange experiment): ==10840== /usr/lib/valgrind/../../bin/vgdb --pid=10840 ...command... ==10840== ==10840== TO DEBUG THIS PROCESS USING GDB: start GDB like this ==10840== /path/to/gdb ./mechanize ==10840== and then give GDB the following command ==10840== target remote | /usr/lib/valgrind/../../bin/vgdb --pid=10840 ==10840== --pid is optional if only one valgrind process is running ==10840== --10840-- REDIR: 0x40184e0 (strlen) redirected to 0x3806ae64 (???) --10840-- REDIR: 0x4018260 (index) redirected to 0x3806ae3f (???) --10840-- Reading syms from /usr/lib/valgrind/vgpreload_core-x86-linux.so --10840-- object doesn't have a symbol table --10840-- Reading syms from /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so --10840-- object doesn't have a symbol table --10840-- Reading syms from /usr/lib/libcurl.so.4.3.0 --10840-- object doesn't have a symbol table --10840-- Reading syms from /usr/lib/libstdc++.so.6.0.17 --10840-- object doesn't have a symbol table --10840-- Reading syms from /usr/lib/libm-2.17.so --10840-- object doesn't have a symbol table --10840-- Reading syms from /usr/lib/libgcc_s.so.1 --10840-- object doesn't have a symbol table --10840-- Reading syms from /usr/lib/libc-2.17.so --10840-- Reading syms from /usr/lib/libpthread-2.17.so --10840-- Reading syms from /usr/lib/libssh2.so.1.0.1 --10840-- object doesn't have a symbol table --10840-- Reading syms from /usr/lib/librt-2.17.so --10840-- object doesn't have a symbol table --10840-- Reading syms from /usr/lib/libssl.so.1.0.0 --10840-- Reading syms from /usr/lib/libcrypto.so.1.0.0 --10840-- Reading syms from /usr/lib/libz.so.1.2.7 --10840-- object doesn't have a symbol table --10840-- Reading syms from /usr/lib/libdl-2.17.so --10840-- object doesn't have a symbol table --10840-- REDIR: 0x4280510 (strnlen) redirected to 0x4023590 (_vgnU_ifunc_wrapper) --10840-- REDIR: 0x4281a90 (strncasecmp) redirected to 0x4023590 (_vgnU_ifunc_wrapper) --10840-- REDIR: 0x4286aa0 (memrchr) redirected to 0x4023590 (_vgnU_ifunc_wrapper) --10840-- REDIR: 0x429aed0 (wcslen) redirected to 0x4023590 (_vgnU_ifunc_wrapper) --10840-- REDIR: 0x427fc70 (strcmp) redirected to 0x4023590 (_vgnU_ifunc_wrapper) --10840-- REDIR: 0x4299950 (strstr) redirected to 0x4023590 (_vgnU_ifunc_wrapper) --10840-- REDIR: 0x4299450 (__GI_strstr) redirected to 0x402eb70 (strstr) --10840-- REDIR: 0x42806b0 (__GI_strrchr) redirected to 0x402bb10 (__GI_strrchr) --10840-- REDIR: 0x4280450 (__GI_strlen) redirected to 0x402bf40 (__GI_strlen) --10840-- REDIR: 0x4345100 (__strcmp_ssse3) redirected to 0x402cbb0 (strcmp) --10840-- REDIR: 0x4280400 (strlen) redirected to 0x4023590 (_vgnU_ifunc_wrapper) --10840-- REDIR: 0x4286e70 (__strlen_sse2_bsf) redirected to 0x402bf20 (strlen) --10840-- REDIR: 0x427ba50 (malloc) redirected to 0x402b640 (malloc) --10840-- REDIR: 0x4281170 (bcmp) redirected to 0x4023590 (_vgnU_ifunc_wrapper) --10840-- REDIR: 0x434cff0 (__memcmp_ssse3) redirected to 0x402dde0 (bcmp) --10840-- REDIR: 0x427bf00 (realloc) redirected to 0x402b850 (realloc) --10840-- REDIR: 0x4286d40 (__GI_strncmp) redirected to 0x402c450 (__GI_strncmp) --10840-- REDIR: 0x42818b0 (__GI_stpcpy) redirected to 0x402df90 (__GI_stpcpy) --10840-- REDIR: 0x4280600 (strncpy) redirected to 0x4023590 (_vgnU_ifunc_wrapper) --10840-- REDIR: 0x4288840 (__strncpy_ssse3) redirected to 0x402c100 (strncpy) --10840-- REDIR: 0x427be50 (free) redirected to 0x402a3f0 (free) --10840-- REDIR: 0x427c340 (calloc) redirected to 0x4029510 (calloc) --10840-- REDIR: 0x4102e00 (operator new(unsigned int)) redirected to 0x402b0c0 (operator new(unsigned int)) --10840-- REDIR: 0x4281bc0 (memcpy) redirected to 0x4023590 (_vgnU_ifunc_wrapper) --10840-- REDIR: 0x4338b20 (__memcpy_ssse3) redirected to 0x402d270 (memcpy) --10840-- REDIR: 0x4100b30 (operator delete(void*)) redirected to 0x4029f20 (operator delete(void*)) --10840-- REDIR: 0x4281a40 (strcasecmp) redirected to 0x4023590 (_vgnU_ifunc_wrapper) --10840-- REDIR: 0x4347f60 (__strcasecmp_ssse3) redirected to 0x402c4e0 (strcasecmp) --10840-- REDIR: 0x4282e60 (__GI___rawmemchr) redirected to 0x402e7b0 (__GI___rawmemchr) --10840-- REDIR: 0x427fa60 (index) redirected to 0x4023590 (_vgnU_ifunc_wrapper) --10840-- REDIR: 0x4297f10 (__strchr_sse2_bsf) redirected to 0x402bba0 (index) --10840-- REDIR: 0x427fab0 (__GI_strchr) redirected to 0x402bbd0 (__GI_strchr) --10840-- REDIR: 0x4280660 (rindex) redirected to 0x4023590 (_vgnU_ifunc_wrapper) --10840-- REDIR: 0x4298020 (__strrchr_sse2_bsf) redirected to 0x402bae0 (rindex) --10840-- REDIR: 0x427fcc0 (__GI_strcmp) redirected to 0x402cc00 (__GI_strcmp) --10840-- REDIR: 0x4282f30 (strchrnul) redirected to 0x402e760 (strchrnul) --10840-- REDIR: 0x427fd90 (__GI_strcpy) redirected to 0x402c030 (__GI_strcpy) --10840-- REDIR: 0x4280f80 (memchr) redirected to 0x4023590 (_vgnU_ifunc_wrapper) --10840-- REDIR: 0x4298210 (__memchr_sse2_bsf) redirected to 0x402ccf0 (memchr) --10840-- REDIR: 0x4282e10 (rawmemchr) redirected to 0x4023590 (_vgnU_ifunc_wrapper) --10840-- REDIR: 0x42989f0 (__rawmemchr_sse2_bsf) redirected to 0x402e790 (rawmemchr) ==10840== Conditional jump or move depends on uninitialised value(s) ==10840== at 0x402BF37: strlen (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==10840== by 0x416B11A: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.17) ==10840== by 0x804A5A9: ??? (in /home/raptor/mechanize_plus_plus/mechanize/bin/Debug/mechanize) ==10840== by 0x406A0B2: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x408C71A: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x408CAE9: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4081D6A: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4082EEE: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4083AC2: curl_easy_perform (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x68B89C03: ??? ==10840== --10840-- REDIR: 0x42805b0 (strncmp) redirected to 0x4023590 (_vgnU_ifunc_wrapper) --10840-- REDIR: 0x4346570 (__strncmp_ssse3) redirected to 0x402c3c0 (strncmp) ==10840== Invalid read of size 1 ==10840== at 0x4068361: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4076C6F: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4082D8C: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4083AC2: curl_easy_perform (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x8053256: ??? (in /home/raptor/mechanize_plus_plus/mechanize/bin/Debug/mechanize) ==10840== by 0x80499D4: ??? (in /home/raptor/mechanize_plus_plus/mechanize/bin/Debug/mechanize) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== Address 0x468b43c is 12 bytes inside a block of size 174 free'd ==10840== at 0x4029F8C: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==10840== by 0x41688BA: std::string::_Rep::_M_destroy(std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.17) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== ==10840== Invalid read of size 1 ==10840== at 0x402D48B: memcpy (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==10840== by 0x40660C1: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x406853F: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4076C6F: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4082D8C: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4083AC2: curl_easy_perform (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x8053256: ??? (in /home/raptor/mechanize_plus_plus/mechanize/bin/Debug/mechanize) ==10840== by 0x80499D4: ??? (in /home/raptor/mechanize_plus_plus/mechanize/bin/Debug/mechanize) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== Address 0x468b4dc is 172 bytes inside a block of size 174 free'd ==10840== at 0x4029F8C: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==10840== by 0x41688BA: std::string::_Rep::_M_destroy(std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.17) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== ==10840== Invalid read of size 4 ==10840== at 0x4099022: curl_slist_append (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== Address 0x468b57c is 4 bytes inside a block of size 8 free'd ==10840== at 0x402A45C: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==10840== by 0x409908C: curl_slist_free_all (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x804FAAB: ??? (in /home/raptor/mechanize_plus_plus/mechanize/bin/Debug/mechanize) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== ==10840== Invalid write of size 4 ==10840== at 0x4099029: curl_slist_append (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== Address 0x46af23c is 4 bytes inside a block of size 8 free'd ==10840== at 0x402A45C: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==10840== by 0x409908C: curl_slist_free_all (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x804FAAB: ??? (in /home/raptor/mechanize_plus_plus/mechanize/bin/Debug/mechanize) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== ==10840== ==10840== HEAP SUMMARY: ==10840== in use at exit: 48,448 bytes in 3,104 blocks ==10840== total heap usage: 3,831 allocs, 727 frees, 209,408 bytes allocated ==10840== ==10840== Searching for pointers to 3,104 not-freed blocks ==10840== Checked 244,012 bytes ==10840== ==10840== 16 (8 direct, 8 indirect) bytes in 1 blocks are definitely lost in loss record 13 of 87 ==10840== at 0x402B6A8: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==10840== by 0x4098FF3: curl_slist_append (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== ==10840== LEAK SUMMARY: ==10840== definitely lost: 8 bytes in 1 blocks ==10840== indirectly lost: 8 bytes in 1 blocks ==10840== possibly lost: 0 bytes in 0 blocks ==10840== still reachable: 48,432 bytes in 3,102 blocks ==10840== suppressed: 0 bytes in 0 blocks ==10840== Reachable blocks (those to which a pointer was found) are not shown. ==10840== To see them, rerun with: --leak-check=full --show-reachable=yes ==10840== ==10840== Use --track-origins=yes to see where uninitialised values come from ==10840== ERROR SUMMARY: 334 errors from 6 contexts (suppressed: 0 from 0) ==10840== ==10840== 1 errors in context 1 of 6: ==10840== Invalid write of size 4 ==10840== at 0x4099029: curl_slist_append (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== Address 0x46af23c is 4 bytes inside a block of size 8 free'd ==10840== at 0x402A45C: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==10840== by 0x409908C: curl_slist_free_all (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x804FAAB: ??? (in /home/raptor/mechanize_plus_plus/mechanize/bin/Debug/mechanize) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== ==10840== ==10840== 2 errors in context 2 of 6: ==10840== Conditional jump or move depends on uninitialised value(s) ==10840== at 0x402BF37: strlen (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==10840== by 0x416B11A: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.17) ==10840== by 0x804A5A9: ??? (in /home/raptor/mechanize_plus_plus/mechanize/bin/Debug/mechanize) ==10840== by 0x406A0B2: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x408C71A: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x408CAE9: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4081D6A: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4082EEE: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4083AC2: curl_easy_perform (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x68B89C03: ??? ==10840== ==10840== ==10840== 7 errors in context 3 of 6: ==10840== Invalid read of size 4 ==10840== at 0x4099022: curl_slist_append (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== Address 0x468b57c is 4 bytes inside a block of size 8 free'd ==10840== at 0x402A45C: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==10840== by 0x409908C: curl_slist_free_all (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x804FAAB: ??? (in /home/raptor/mechanize_plus_plus/mechanize/bin/Debug/mechanize) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== ==10840== ==10840== 161 errors in context 4 of 6: ==10840== Invalid read of size 1 ==10840== at 0x402D48B: memcpy (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==10840== by 0x40660C1: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x406853F: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4076C6F: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4082D8C: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4083AC2: curl_easy_perform (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x8053256: ??? (in /home/raptor/mechanize_plus_plus/mechanize/bin/Debug/mechanize) ==10840== by 0x80499D4: ??? (in /home/raptor/mechanize_plus_plus/mechanize/bin/Debug/mechanize) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== Address 0x468b4dc is 172 bytes inside a block of size 174 free'd ==10840== at 0x4029F8C: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==10840== by 0x41688BA: std::string::_Rep::_M_destroy(std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.17) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== ==10840== ==10840== 162 errors in context 5 of 6: ==10840== Invalid read of size 1 ==10840== at 0x4068361: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4076C6F: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4082D8C: ??? (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x4083AC2: curl_easy_perform (in /usr/lib/libcurl.so.4.3.0) ==10840== by 0x8053256: ??? (in /home/raptor/mechanize_plus_plus/mechanize/bin/Debug/mechanize) ==10840== by 0x80499D4: ??? (in /home/raptor/mechanize_plus_plus/mechanize/bin/Debug/mechanize) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== Address 0x468b43c is 12 bytes inside a block of size 174 free'd ==10840== at 0x4029F8C: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) ==10840== by 0x41688BA: std::string::_Rep::_M_destroy(std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.17) ==10840== by 0x421B824: (below main) (in /usr/lib/libc-2.17.so) ==10840== ==10840== ERROR SUMMARY: 334 errors from 6 contexts (suppressed: 0 from 0)
------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html
