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

remove memory safety bugs #3

Open
sorousherafat opened this issue May 5, 2023 · 0 comments
Open

remove memory safety bugs #3

sorousherafat opened this issue May 5, 2023 · 0 comments

Comments

@sorousherafat
Copy link
Owner

valgrind output:

==427843== Memcheck, a memory error detector
==427843== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==427843== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==427843== Command: ./vjudge -t test/testdir/ test/ram.v test/ram2.v
==427843== 
==427843== Conditional jump or move depends on uninitialised value(s)
==427843==    at 0x10A557: parse_instruction (libvcd.c:102)
==427843==    by 0x10A25B: open_vcd (libvcd.c:37)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843==  Uninitialised value was created by a heap allocation
==427843==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x10A3BA: init_vcd (libvcd.c:77)
==427843==    by 0x10A236: open_vcd (libvcd.c:31)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
Test 'ram2' failed for src file 'test/ram.v'
Test 'ram' passed for src file 'test/ram.v'
src file 'test/ram.v': 1/2 tests passed

Test 'ram2' failed for src file 'test/ram2.v'
Test 'ram' passed for src file 'test/ram2.v'
src file 'test/ram2.v': 1/2 tests passed

==427843== 
==427843== HEAP SUMMARY:
==427843==     in use at exit: 2,285,044 bytes in 1,117 blocks
==427843==   total heap usage: 2,084 allocs, 967 frees, 2,406,644 bytes allocated
==427843== 
==427843== 8 bytes in 4 blocks are indirectly lost in loss record 1 of 23
==427843==    at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x48D8695: __vfscanf_internal (vfscanf-internal.c:2987)
==427843==    by 0x48D529C: __isoc99_fscanf (isoc99_fscanf.c:30)
==427843==    by 0x10A666: parse_instruction (libvcd.c:119)
==427843==    by 0x10A25B: open_vcd (libvcd.c:37)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== 9 bytes in 2 blocks are still reachable in loss record 2 of 23
==427843==    at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x48D8695: __vfscanf_internal (vfscanf-internal.c:2987)
==427843==    by 0x48D53E1: __isoc99_sscanf (isoc99_sscanf.c:31)
==427843==    by 0x10A1A4: try_get_test_name (main.c:387)
==427843==    by 0x109A03: load_tests (main.c:237)
==427843==    by 0x109458: main (main.c:118)
==427843== 
==427843== 9 bytes in 2 blocks are definitely lost in loss record 3 of 23
==427843==    at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x48D8695: __vfscanf_internal (vfscanf-internal.c:2987)
==427843==    by 0x48D53E1: __isoc99_sscanf (isoc99_sscanf.c:31)
==427843==    by 0x10A1A4: try_get_test_name (main.c:387)
==427843==    by 0x109A03: load_tests (main.c:237)
==427843==    by 0x109458: main (main.c:118)
==427843== 
==427843== 34 bytes in 6 blocks are still reachable in loss record 4 of 23
==427843==    at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x48D8695: __vfscanf_internal (vfscanf-internal.c:2987)
==427843==    by 0x48D53E1: __isoc99_sscanf (isoc99_sscanf.c:31)
==427843==    by 0x10A795: parse_assignment (libvcd.c:140)
==427843==    by 0x10A2BF: open_vcd (libvcd.c:48)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== 60 bytes in 4 blocks are indirectly lost in loss record 5 of 23
==427843==    at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x48D8695: __vfscanf_internal (vfscanf-internal.c:2987)
==427843==    by 0x48D529C: __isoc99_fscanf (isoc99_fscanf.c:30)
==427843==    by 0x10A622: parse_instruction (libvcd.c:114)
==427843==    by 0x10A25B: open_vcd (libvcd.c:37)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== 82 bytes in 12 blocks are still reachable in loss record 6 of 23
==427843==    at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x48D8695: __vfscanf_internal (vfscanf-internal.c:2987)
==427843==    by 0x48D529C: __isoc99_fscanf (isoc99_fscanf.c:30)
==427843==    by 0x109C43: read_assertions (main.c:280)
==427843==    by 0x109BAA: read_test_assertions (main.c:272)
==427843==    by 0x109A41: load_tests (main.c:245)
==427843==    by 0x109458: main (main.c:118)
==427843== 
==427843== 100 bytes in 4 blocks are indirectly lost in loss record 7 of 23
==427843==    at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x48D8695: __vfscanf_internal (vfscanf-internal.c:2987)
==427843==    by 0x48D529C: __isoc99_fscanf (isoc99_fscanf.c:30)
==427843==    by 0x10A5E0: parse_instruction (libvcd.c:109)
==427843==    by 0x10A25B: open_vcd (libvcd.c:37)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== 144 bytes in 72 blocks are indirectly lost in loss record 8 of 23
==427843==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x10A74F: parse_assignment (libvcd.c:137)
==427843==    by 0x10A2BF: open_vcd (libvcd.c:48)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== 144 bytes in 72 blocks are definitely lost in loss record 9 of 23
==427843==    at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x48D8695: __vfscanf_internal (vfscanf-internal.c:2987)
==427843==    by 0x48D53E1: __isoc99_sscanf (isoc99_sscanf.c:31)
==427843==    by 0x10A773: parse_assignment (libvcd.c:138)
==427843==    by 0x10A2BF: open_vcd (libvcd.c:48)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== 208 bytes in 80 blocks are definitely lost in loss record 10 of 23
==427843==    at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x48D8695: __vfscanf_internal (vfscanf-internal.c:2987)
==427843==    by 0x48D529C: __isoc99_fscanf (isoc99_fscanf.c:30)
==427843==    by 0x10A52D: parse_instruction (libvcd.c:100)
==427843==    by 0x10A25B: open_vcd (libvcd.c:37)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== 296 bytes in 148 blocks are definitely lost in loss record 11 of 23
==427843==    at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x48D8695: __vfscanf_internal (vfscanf-internal.c:2987)
==427843==    by 0x48D53E1: __isoc99_sscanf (isoc99_sscanf.c:31)
==427843==    by 0x10A795: parse_assignment (libvcd.c:140)
==427843==    by 0x10A2BF: open_vcd (libvcd.c:48)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== 316 bytes in 56 blocks are indirectly lost in loss record 12 of 23
==427843==    at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x48D8695: __vfscanf_internal (vfscanf-internal.c:2987)
==427843==    by 0x48D529C: __isoc99_fscanf (isoc99_fscanf.c:30)
==427843==    by 0x10A52D: parse_instruction (libvcd.c:100)
==427843==    by 0x10A25B: open_vcd (libvcd.c:37)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== 826 bytes in 142 blocks are indirectly lost in loss record 13 of 23
==427843==    at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x48D8695: __vfscanf_internal (vfscanf-internal.c:2987)
==427843==    by 0x48D53E1: __isoc99_sscanf (isoc99_sscanf.c:31)
==427843==    by 0x10A795: parse_assignment (libvcd.c:140)
==427843==    by 0x10A2BF: open_vcd (libvcd.c:48)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== 944 bytes in 2 blocks are still reachable in loss record 14 of 23
==427843==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x48F26CD: __fopen_internal (iofopen.c:65)
==427843==    by 0x48F26CD: fopen@@GLIBC_2.2.5 (iofopen.c:86)
==427843==    by 0x109D56: open_assertion_file (main.c:306)
==427843==    by 0x109B93: read_test_assertions (main.c:271)
==427843==    by 0x109A41: load_tests (main.c:245)
==427843==    by 0x109458: main (main.c:118)
==427843== 
==427843== 988 bytes in 208 blocks are definitely lost in loss record 15 of 23
==427843==    at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x48D8695: __vfscanf_internal (vfscanf-internal.c:2987)
==427843==    by 0x48D529C: __isoc99_fscanf (isoc99_fscanf.c:30)
==427843==    by 0x10A415: parse_instruction (libvcd.c:83)
==427843==    by 0x10A25B: open_vcd (libvcd.c:37)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== 1,372 bytes in 220 blocks are definitely lost in loss record 16 of 23
==427843==    at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x48D8695: __vfscanf_internal (vfscanf-internal.c:2987)
==427843==    by 0x48D529C: __isoc99_fscanf (isoc99_fscanf.c:30)
==427843==    by 0x10A725: parse_assignment (libvcd.c:134)
==427843==    by 0x10A2BF: open_vcd (libvcd.c:48)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== 1,888 bytes in 4 blocks are still reachable in loss record 17 of 23
==427843==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x48F26CD: __fopen_internal (iofopen.c:65)
==427843==    by 0x48F26CD: fopen@@GLIBC_2.2.5 (iofopen.c:86)
==427843==    by 0x10A215: open_vcd (libvcd.c:26)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== 8,192 bytes in 4 blocks are indirectly lost in loss record 18 of 23
==427843==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x10A3BA: init_vcd (libvcd.c:77)
==427843==    by 0x10A236: open_vcd (libvcd.c:31)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== 8,192 bytes in 2 blocks are definitely lost in loss record 19 of 23
==427843==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x109B69: read_test_assertions (main.c:268)
==427843==    by 0x109A41: load_tests (main.c:245)
==427843==    by 0x109458: main (main.c:118)
==427843== 
==427843== 32,816 bytes in 1 blocks are still reachable in loss record 20 of 23
==427843==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x495937A: __alloc_dir (opendir.c:115)
==427843==    by 0x495937A: opendir_tail (opendir.c:63)
==427843==    by 0x495937A: opendir (opendir.c:86)
==427843==    by 0x109FC8: check_files_existence (main.c:351)
==427843==    by 0x1099C0: check_input (main.c:227)
==427843==    by 0x10943D: main (main.c:115)
==427843== 
==427843== 393,216 bytes in 12 blocks are definitely lost in loss record 21 of 23
==427843==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x10A4F8: parse_instruction (libvcd.c:98)
==427843==    by 0x10A25B: open_vcd (libvcd.c:37)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== 1,835,008 bytes in 56 blocks are indirectly lost in loss record 22 of 23
==427843==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x10A4F8: parse_instruction (libvcd.c:98)
==427843==    by 0x10A25B: open_vcd (libvcd.c:37)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== 1,844,846 (192 direct, 1,844,654 indirect) bytes in 4 blocks are definitely lost in loss record 23 of 23
==427843==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==427843==    by 0x10A39F: init_vcd (libvcd.c:76)
==427843==    by 0x10A236: open_vcd (libvcd.c:31)
==427843==    by 0x1097A9: run_test (main.c:181)
==427843==    by 0x109513: test_src_file (main.c:134)
==427843==    by 0x1094B5: test_src_files (main.c:126)
==427843==    by 0x109469: main (main.c:120)
==427843== 
==427843== LEAK SUMMARY:
==427843==    definitely lost: 404,617 bytes in 748 blocks
==427843==    indirectly lost: 1,844,654 bytes in 342 blocks
==427843==      possibly lost: 0 bytes in 0 blocks
==427843==    still reachable: 35,773 bytes in 27 blocks
==427843==         suppressed: 0 bytes in 0 blocks
==427843== 
==427843== For lists of detected and suppressed errors, rerun with: -s
==427843== ERROR SUMMARY: 65 errors from 10 contexts (suppressed: 0 from 0)
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

No branches or pull requests

1 participant