{"action":"created","issue":{"url":"https://api.github.com/repos/rgamble/libcsv/issues/3","repository_url":"https://api.github.com/repos/rgamble/libcsv","labels_url":"https://api.github.com/repos/rgamble/libcsv/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/rgamble/libcsv/issues/3/comments","events_url":"https://api.github.com/repos/rgamble/libcsv/issues/3/events","html_url":"https://github.com/rgamble/libcsv/issues/3","id":196240468,"number":3,"title":"Memory leaks","user":{"login":"bobhairgrove","id":10685967,"avatar_url":"https://avatars.githubusercontent.com/u/10685967?v=3","gravatar_id":"","url":"https://api.github.com/users/bobhairgrove","html_url":"https://github.com/bobhairgrove","followers_url":"https://api.github.com/users/bobhairgrove/followers","following_url":"https://api.github.com/users/bobhairgrove/following{/other_user}","gists_url":"https://api.github.com/users/bobhairgrove/gists{/gist_id}","starred_url":"https://api.github.com/users/bobhairgrove/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bobhairgrove/subscriptions","organizations_url":"https://api.github.com/users/bobhairgrove/orgs","repos_url":"https://api.github.com/users/bobhairgrove/repos","events_url":"https://api.github.com/users/bobhairgrove/events{/privacy}","received_events_url":"https://api.github.com/users/bobhairgrove/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-17T20:13:44Z","updated_at":"2016-12-18T09:10:44Z","closed_at":null,"body":"These memory leaks were reported by running `csvcheck`, `csvcut` and `csvgrep` under `valgrind`, but some of them seem to be coming from `libcsv`. However, `csvcount` passed the leak test, so the problems might be in `csvutils`.\r\n\r\nI am attaching the CSV file I used to run these:\r\n[my_test.csv.zip](https://github.com/rgamble/libcsv/files/659067/my_test.csv.zip)\r\n\r\n**csvcheck:**\r\n```\r\nbob@mylaptop:~/libcsv-master/tests$ valgrind --leak-check=full csvcheck my_test.csv\r\n==27156== Memcheck, a memory error detector\r\n==27156== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.\r\n==27156== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info\r\n==27156== Command: csvcheck my_test.csv\r\n==27156== \r\nmy_test.csv well-formed\r\n==27156== \r\n==27156== HEAP SUMMARY:\r\n==27156==     in use at exit: 128 bytes in 1 blocks\r\n==27156==   total heap usage: 4 allocs, 3 frees, 5,800 bytes allocated\r\n==27156== \r\n==27156== 128 bytes in 1 blocks are definitely lost in loss record 1 of 1\r\n==27156==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n==27156==    by 0x4C2FDEF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n==27156==    by 0x4E3ABA2: csv_increase_buffer (libcsv.c:291)\r\n==27156==    by 0x4E3B745: csv_parse (libcsv.c:325)\r\n==27156==    by 0x40119C: check_file (in /usr/local/bin/csvcheck)\r\n==27156==    by 0x401497: main (in /usr/local/bin/csvcheck)\r\n==27156== \r\n==27156== LEAK SUMMARY:\r\n==27156==    definitely lost: 128 bytes in 1 blocks\r\n==27156==    indirectly lost: 0 bytes in 0 blocks\r\n==27156==      possibly lost: 0 bytes in 0 blocks\r\n==27156==    still reachable: 0 bytes in 0 blocks\r\n==27156==         suppressed: 0 bytes in 0 blocks\r\n==27156== \r\n==27156== For counts of detected and suppressed errors, rerun with: -v\r\n==27156== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)\r\n```\r\n\r\n**csvcut:**\r\n```\r\nbob@mylaptop:~/libcsv-master/tests$ valgrind --leak-check=full csvcut -f 1 my_test.csv\r\n==27168== Memcheck, a memory error detector\r\n==27168== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.\r\n==27168== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info\r\n==27168== Command: csvcut -f 1 my_test.csv\r\n==27168== \r\n\"lastname\"\r\n\"Doe\"\r\n\"Lamb\"\r\n(...snip...)\r\n==27168== \r\n==27168== HEAP SUMMARY:\r\n==27168==     in use at exit: 162 bytes in 3 blocks\r\n==27168==   total heap usage: 22 allocs, 19 frees, 6,444 bytes allocated\r\n==27168== \r\n==27168== 2 bytes in 1 blocks are definitely lost in loss record 1 of 3\r\n==27168==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n==27168==    by 0x4025A6: xmalloc (in /usr/local/bin/csvcut)\r\n==27168==    by 0x4026E9: Strndup (in /usr/local/bin/csvcut)\r\n==27168==    by 0x401A16: field_spec_cb1 (in /usr/local/bin/csvcut)\r\n==27168==    by 0x4E3ADA9: csv_fini (libcsv.c:185)\r\n==27168==    by 0x4015FD: process_field_specs (in /usr/local/bin/csvcut)\r\n==27168==    by 0x4024B4: main (in /usr/local/bin/csvcut)\r\n==27168== \r\n==27168== 128 bytes in 1 blocks are definitely lost in loss record 3 of 3\r\n==27168==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n==27168==    by 0x4C2FDEF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n==27168==    by 0x4E3ABA2: csv_increase_buffer (libcsv.c:291)\r\n==27168==    by 0x4E3B745: csv_parse (libcsv.c:325)\r\n==27168==    by 0x4015D2: process_field_specs (in /usr/local/bin/csvcut)\r\n==27168==    by 0x4024B4: main (in /usr/local/bin/csvcut)\r\n==27168== \r\n==27168== LEAK SUMMARY:\r\n==27168==    definitely lost: 130 bytes in 2 blocks\r\n==27168==    indirectly lost: 0 bytes in 0 blocks\r\n==27168==      possibly lost: 0 bytes in 0 blocks\r\n==27168==    still reachable: 32 bytes in 1 blocks\r\n==27168==         suppressed: 0 bytes in 0 blocks\r\n==27168== Reachable blocks (those to which a pointer was found) are not shown.\r\n==27168== To see them, rerun with: --leak-check=full --show-leak-kinds=all\r\n==27168== \r\n==27168== For counts of detected and suppressed errors, rerun with: -v\r\n==27168== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)\r\n```\r\n\r\n**csvgrep:**\r\n```\r\nbob@mylaptop:~/libcsv-master/tests$ valgrind --leak-check=full csvgrep -f 1 Doe my_test.csv\r\n==27209== Memcheck, a memory error detector\r\n==27209== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.\r\n==27209== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info\r\n==27209== Command: csvgrep -f 1 Doe my_test.csv\r\n==27209== \r\n\"Doe\",\"John\",\"SE-1\",\"CS-101/EN-103/PH-102/MA-103\",\"john.doe@gmail.com\"\r\n\"Doe\",\"John\",\"SE-1\",\"CS-101/EN-103/PH-102/MA-103\",\"john.doe@gmail.com\"\r\n(...snip...)\r\n==27209== \r\n==27209== HEAP SUMMARY:\r\n==27209==     in use at exit: 11,693 bytes in 965 blocks\r\n==27209==   total heap usage: 1,928 allocs, 963 frees, 23,234 bytes allocated\r\n==27209== \r\n==27209== 2 bytes in 1 blocks are definitely lost in loss record 1 of 20\r\n==27209==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n==27209==    by 0x402B80: xmalloc (in /usr/local/bin/csvgrep)\r\n==27209==    by 0x402CC3: Strndup (in /usr/local/bin/csvgrep)\r\n==27209==    by 0x401865: field_spec_cb1 (in /usr/local/bin/csvgrep)\r\n==27209==    by 0x4E3ADA9: csv_fini (libcsv.c:185)\r\n==27209==    by 0x401728: process_field_specs (in /usr/local/bin/csvgrep)\r\n==27209==    by 0x40292E: main (in /usr/local/bin/csvgrep)\r\n==27209== \r\n==27209== 128 bytes in 1 blocks are definitely lost in loss record 15 of 20\r\n==27209==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n==27209==    by 0x4C2FDEF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n==27209==    by 0x4E3ABA2: csv_increase_buffer (libcsv.c:291)\r\n==27209==    by 0x4E3B745: csv_parse (libcsv.c:325)\r\n==27209==    by 0x4016FD: process_field_specs (in /usr/local/bin/csvgrep)\r\n==27209==    by 0x40292E: main (in /usr/local/bin/csvgrep)\r\n==27209== \r\n==27209== 4,203 bytes in 933 blocks are definitely lost in loss record 19 of 20\r\n==27209==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)\r\n==27209==    by 0x402B80: xmalloc (in /usr/local/bin/csvgrep)\r\n==27209==    by 0x402CC3: Strndup (in /usr/local/bin/csvgrep)\r\n==27209==    by 0x401C8A: matches_pattern (in /usr/local/bin/csvgrep)\r\n==27209==    by 0x40228E: cb2 (in /usr/local/bin/csvgrep)\r\n==27209==    by 0x4E3B110: csv_parse (libcsv.c:414)\r\n==27209==    by 0x4024CC: grep_file (in /usr/local/bin/csvgrep)\r\n==27209==    by 0x402AE0: main (in /usr/local/bin/csvgrep)\r\n==27209== \r\n==27209== LEAK SUMMARY:\r\n==27209==    definitely lost: 4,333 bytes in 935 blocks\r\n==27209==    indirectly lost: 0 bytes in 0 blocks\r\n==27209==      possibly lost: 0 bytes in 0 blocks\r\n==27209==    still reachable: 7,360 bytes in 30 blocks\r\n==27209==         suppressed: 0 bytes in 0 blocks\r\n==27209== Reachable blocks (those to which a pointer was found) are not shown.\r\n==27209== To see them, rerun with: --leak-check=full --show-leak-kinds=all\r\n==27209== \r\n==27209== For counts of detected and suppressed errors, rerun with: -v\r\n==27209== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)\r\n```"},"comment":{"url":"https://api.github.com/repos/rgamble/libcsv/issues/comments/267810884","html_url":"https://github.com/rgamble/libcsv/issues/3#issuecomment-267810884","issue_url":"https://api.github.com/repos/rgamble/libcsv/issues/3","id":267810884,"user":{"login":"bobhairgrove","id":10685967,"avatar_url":"https://avatars.githubusercontent.com/u/10685967?v=3","gravatar_id":"","url":"https://api.github.com/users/bobhairgrove","html_url":"https://github.com/bobhairgrove","followers_url":"https://api.github.com/users/bobhairgrove/followers","following_url":"https://api.github.com/users/bobhairgrove/following{/other_user}","gists_url":"https://api.github.com/users/bobhairgrove/gists{/gist_id}","starred_url":"https://api.github.com/users/bobhairgrove/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bobhairgrove/subscriptions","organizations_url":"https://api.github.com/users/bobhairgrove/orgs","repos_url":"https://api.github.com/users/bobhairgrove/repos","events_url":"https://api.github.com/users/bobhairgrove/events{/privacy}","received_events_url":"https://api.github.com/users/bobhairgrove/received_events","type":"User","site_admin":false},"created_at":"2016-12-18T09:10:44Z","updated_at":"2016-12-18T09:10:44Z","body":"I just ran `csvcheck` through a debugger with a breakpoint set on the library function `csv_free()`. It was never called.\r\n\r\nSeems like `csv_fini()` needs to call it before returning."}}
{"actor":{"display_login":"bobhairgrove"}}