Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Valgrind error with very simple program

FlyingHermes
New Contributor I
1,189 Views

The following simple program

Program Main
  implicit none
  write(*,*) "123"
End Program

gives some errors when run through valgrind.

Here is the output

$ ifort -v
ifort version 16.0.2

$ ifort -g main.f90

$ valgrind -v --track-origins=yes --leak-check=full ./a.out                               
==25729== Memcheck, a memory error detector
==25729== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==25729== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==25729== Command: ./a.out
==25729== 
--25729-- Valgrind options:
--25729--    -v
--25729--    --track-origins=yes
--25729--    --leak-check=full
--25729-- Contents of /proc/version:
--25729--   Linux version 4.4.2-301.fc23.x86_64 (mockbuild@bkernel01.phx2.fedoraproject.org) (gcc version 5.3.1 20151207 (Red Hat 5.3.1-2) (GCC) ) #1 SMP Tue Feb 23 19:00:38 UTC 2016
--25729-- 
==25729== 
==25729== TO CONTROL THIS PROCESS USING vgdb (which you probably
==25729== don't want to do, unless you know exactly what you're doing,
==25729== or are doing some strange experiment):
==25729==   /usr/lib64/valgrind/../../bin/vgdb --pid=25729 ...command...
==25729== 
==25729== TO DEBUG THIS PROCESS USING GDB: start GDB like this
==25729==   /path/to/gdb ./a.out
==25729== and then give GDB the following command
==25729==   target remote | /usr/lib64/valgrind/../../bin/vgdb --pid=25729
==25729== --pid is optional if only one valgrind process is running
==25729== 
--25729-- REDIR: 0x4019b90 (ld-linux-x86-64.so.2:strlen) redirected to 0x3809e2b1 (???)
--25729-- Reading syms from /usr/lib64/valgrind/vgpreload_core-amd64-linux.so
--25729-- Reading syms from /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so
==25729== WARNING: new redirection conflicts with existing -- ignoring it
--25729--     old: 0x04019b90 (strlen              ) R-> (0000.0) 0x3809e2b1 ???
--25729--     new: 0x04019b90 (strlen              ) R-> (2007.0) 0x04c2bce0 strlen
--25729-- REDIR: 0x40198f0 (ld-linux-x86-64.so.2:index) redirected to 0x4c2b880 (index)
--25729-- REDIR: 0x4019b10 (ld-linux-x86-64.so.2:strcmp) redirected to 0x4c2cd90 (strcmp)
--25729-- REDIR: 0x401a850 (ld-linux-x86-64.so.2:mempcpy) redirected to 0x4c2ffb0 (mempcpy)
--25729-- Reading syms from /usr/lib64/libm-2.22.so
--25729-- Reading syms from /usr/lib64/libpthread-2.22.so
--25729-- Reading syms from /usr/lib64/libc-2.22.so
--25729-- Reading syms from /usr/lib64/libgcc_s-5.3.1-20151207.so.1
--25729--    object doesn't have a symbol table
--25729-- Reading syms from /usr/lib64/libdl-2.22.so
--25729-- REDIR: 0x53e2de0 (libc.so.6:strcasecmp) redirected to 0x4a2372e (_vgnU_ifunc_wrapper)
--25729-- REDIR: 0x53de670 (libc.so.6:strcspn) redirected to 0x4a2372e (_vgnU_ifunc_wrapper)
--25729-- REDIR: 0x53e50d0 (libc.so.6:strncasecmp) redirected to 0x4a2372e (_vgnU_ifunc_wrapper)
--25729-- REDIR: 0x53e0b00 (libc.so.6:strpbrk) redirected to 0x4a2372e (_vgnU_ifunc_wrapper)
--25729-- REDIR: 0x53e0e90 (libc.so.6:strspn) redirected to 0x4a2372e (_vgnU_ifunc_wrapper)
--25729-- REDIR: 0x53e256b (libc.so.6:memcpy@GLIBC_2.2.5) redirected to 0x4a2372e (_vgnU_ifunc_wrapper)
--25729-- REDIR: 0x53e0810 (libc.so.6:rindex) redirected to 0x4c2b560 (rindex)
--25729-- REDIR: 0x53d7900 (libc.so.6:malloc) redirected to 0x4c28c7f (malloc)
--25729-- REDIR: 0x53deb10 (libc.so.6:strlen) redirected to 0x4c2bc20 (strlen)
--25729-- REDIR: 0x53e9b40 (libc.so.6:strchrnul) redirected to 0x4c2fae0 (strchrnul)
--25729-- REDIR: 0x53d83f0 (libc.so.6:calloc) redirected to 0x4c2aa02 (calloc)
--25729-- REDIR: 0x477140 (NONE:_intel_fast_memcpy) redirected to 0x4c2e4a0 (_intel_fast_memcpy)
==25729== Conditional jump or move depends on uninitialised value(s)
==25729==    at 0x47C46D: __intel_sse2_strcpy (in /home/Tests/a.out)
==25729==    by 0x446CA0: for__open_proc (in /home/Tests/a.out)
==25729==    by 0x4338BC: for__open_default (in /home/Tests/a.out)
==25729==    by 0x40900D: for_write_seq_lis (in /home/Tests/a.out)
==25729==    by 0x4026ED: MAIN__ (main.f90:5)
==25729==    by 0x40266D: main (in /home/Tests/a.out)
==25729==  Uninitialised value was created by a stack allocation
==25729==    at 0x446B5D: for__open_proc (in /home/Tests/a.out)
==25729== 
==25729== Conditional jump or move depends on uninitialised value(s)
==25729==    at 0x47C46D: __intel_sse2_strcpy (in /home/Tests/a.out)
==25729==    by 0x42C6F5: for__add_to_lf_table (in /home/Tests/a.out)
==25729==    by 0x4484F3: for__open_proc (in /home/Tests/a.out)
==25729==    by 0x4338BC: for__open_default (in /home/Tests/a.out)
==25729==    by 0x40900D: for_write_seq_lis (in /home/Tests/a.out)
==25729==    by 0x4026ED: MAIN__ (main.f90:5)
==25729==    by 0x40266D: main (in /home/Tests/a.out)
==25729==  Uninitialised value was created by a stack allocation
==25729==    at 0x446B5D: for__open_proc (in /home/Tests/a.out)
==25729== 
 123
--25729-- REDIR: 0x53d7c60 (libc.so.6:free) redirected to 0x4c29d79 (free)
==25729== 
==25729== HEAP SUMMARY:
==25729==     in use at exit: 32 bytes in 1 blocks
==25729==   total heap usage: 8 allocs, 7 frees, 12,751 bytes allocated
==25729== 
==25729== Searching for pointers to 1 not-freed blocks
==25729== Checked 242,248 bytes
==25729== 
==25729== LEAK SUMMARY:
==25729==    definitely lost: 0 bytes in 0 blocks
==25729==    indirectly lost: 0 bytes in 0 blocks
==25729==      possibly lost: 0 bytes in 0 blocks
==25729==    still reachable: 32 bytes in 1 blocks
==25729==         suppressed: 0 bytes in 0 blocks
==25729== Reachable blocks (those to which a pointer was found) are not shown.
==25729== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==25729== 
==25729== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
==25729== 
==25729== 1 errors in context 1 of 2:
==25729== Conditional jump or move depends on uninitialised value(s)
==25729==    at 0x47C46D: __intel_sse2_strcpy (in /home/Tests/a.out)
==25729==    by 0x42C6F5: for__add_to_lf_table (in /home/Tests/a.out)
==25729==    by 0x4484F3: for__open_proc (in /home/Tests/a.out)
==25729==    by 0x4338BC: for__open_default (in /home/Tests/a.out)
==25729==    by 0x40900D: for_write_seq_lis (in /home/Tests/a.out)
==25729==    by 0x4026ED: MAIN__ (main.f90:5)
==25729==    by 0x40266D: main (in /home/Tests/a.out)
==25729==  Uninitialised value was created by a stack allocation
==25729==    at 0x446B5D: for__open_proc (in /home/Tests/a.out)
==25729== 
==25729== 
==25729== 1 errors in context 2 of 2:
==25729== Conditional jump or move depends on uninitialised value(s)
==25729==    at 0x47C46D: __intel_sse2_strcpy (in /home/Tests/a.out)
==25729==    by 0x446CA0: for__open_proc (in /home/Tests/a.out)
==25729==    by 0x4338BC: for__open_default (in /home/Tests/a.out)
==25729==    by 0x40900D: for_write_seq_lis (in /home/Tests/a.out)
==25729==    by 0x4026ED: MAIN__ (main.f90:5)
==25729==    by 0x40266D: main (in /home/Tests/a.out)
==25729==  Uninitialised value was created by a stack allocation
==25729==    at 0x446B5D: for__open_proc (in /home/Tests/a.out)
==25729== 
==25729== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

So, the code being so trivial, I guess that these are false positive.

I am correct ?

Is there a way to get ride of them ?

Thanks

0 Kudos
2 Replies
Steven_L_Intel1
Employee
1,189 Views

Yes, you are correct. You have implicitly opened a file, which requires allocated memory. The file is not closed, so that memory remains allocated at the end of the program. Even if the file is closed (and there is an implicit close when the program exits, not all of the bookkeeping memory may be deallocated. valgrind doesn't understand Fortran.

You may not be able to get rid of all of the valgrind complaints.

0 Kudos
FlyingHermes
New Contributor I
1,189 Views

Ok, Thanks for the answer.

0 Kudos
Reply