Mac OS X 10.6.5, Xcode 3.2.4 Searching the FAQ, bug reports, and mailing list, it seems that OS X is quite difficult to support, which is understandable. A lot of people have been having trouble compiling, which I never ran into. I first installed and ran into this bug using MacPorts (3.6.0). I then attempted to test it from the .tar.bz2 (3.6.0). I then attempted taking it from the svn trunk (r 11479). I tested it with a C code of Hello World!, then I saw people were using "echo hi", so I continue with that. I have access to a Mac machine running 10.6.5, and an Ubuntu 10.10 machine. Using the apt-get version on the Ubuntu box, I get "All heap blocks were freed -- no leaks are possible" for both Hello World and "echo hi", as intended, with 0 for "in use at exit" under the "heap summary". I apologize if there's any missing information or if this bug is a mere restatement of another. As always, I can provide additional output or versions. ----- Which Macs default to which kernels: http://support.apple.com/kb/HT3770 How to change the default kernel (Method 2): http://support.apple.com/kb/HT3773 $ uname -a Darwin yoshi-mbp 10.5.0 Darwin Kernel Version 10.5.0: Fri Nov 5 23:19:13 PDT 2010; root:xnu-1504.9.17~1/RELEASE_X86_64 x86_64 $ gcc --version i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664) Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ svn co svn://svn.valgrind.org/valgrind/trunk valgrind-code-svn /* snip */ Checked out revision 11479. $ cd valgrind-code-svn $ ./autogen.sh /* snip, no errors, warnings only */ $ ./configure --prefix=/Users/kumar/Desktop/valgrind-svn /* snip */ Maximum build arch: amd64 Primary build arch: amd64 Secondary build arch: x86 Build OS: darwin Primary build target: AMD64_DARWIN Secondary build target: X86_DARWIN Default supp files: exp-ptrcheck.supp xfree-3.supp xfree-4.supp darwin10-drd.supp darwin10.supp $ make /* snip */ make[2]: Nothing to be done for `all'. $ make install /* snip, ended happily */ $ cd ../valgrind-svn/bin $ ./valgrind -d -v echo hi --26970:1:debuglog DebugLog system started by Stage 1, level 1 logging requested --26970:1:launcher no tool requested, defaulting to 'memcheck' --26970:1:launcher valgrind_lib = /Users/kumar/Desktop/valgrind-svn/lib/valgrind --26970:1:launcher arch 'x86' IS installed --26970:1:launcher arch 'amd64' IS installed --26970:1:launcher arch 'arm' IS NOT installed --26970:1:launcher arch 'ppc32' IS NOT installed --26970:1:launcher arch 'ppc64' IS NOT installed --26970:1:launcher selected arch 'amd64' --26970:1:launcher launcher_name = /Users/kumar/Desktop/valgrind-svn/bin/./valgrind --26970:1:launcher launching /Users/kumar/Desktop/valgrind-svn/lib/valgrind/memcheck-amd64-darwin --26970:1:debuglog DebugLog system started by Stage 2 (main), level 1 logging requested --26970:1:main Welcome to Valgrind version 3.7.0.SVN debug logging --26970:1:main Checking current stack is plausible --26970:1:main Checking initial stack was noted --26970:1:main Starting the address space manager --26970:1:main Address space manager is running --26970:1:main Starting the dynamic memory manager --26970:1:mallocfr newSuperblock at 0x700000001000 (pszB 4194272) owner VALGRIND/tool --26970:1:main Dynamic memory manager is running --26970:1:main Initialise m_debuginfo --26970:1:main VG_(libdir) = /Users/kumar/Desktop/valgrind-svn/lib/valgrind --26970:1:main Getting launcher's name ... --26970:1:main ... /Users/kumar/Desktop/valgrind-svn/bin/./valgrind --26970:1:main Get hardware capabilities ... --26970:1:main ... arch = AMD64, hwcaps = amd64-sse3-cx16 --26970:1:main Getting the working directory at startup --26970:1:main ... /Users/kumar/Desktop/valgrind-svn/bin --26970:1:main Split up command line --26970:1:main (early_) Process Valgrind's command line options --26970:1:main Create initial image --26970:1:initimg Loading client --26970:1:initimg Setup client env --26970:1:main Setup file descriptors --26970:1:main Initialise the tool part 1 (pre_clo_init) --26970:1:mallocfr newSuperblock at 0x700000401000 (pszB 1048544) owner VALGRIND/exectxt --26970:1:main Print help and quit, if requested --26970:1:main (main_) Process Valgrind's command line options, setup logging --26970:1:mallocfr newSuperblock at 0x700000501000 (pszB 1048544) owner VALGRIND/core --26970:1:main Print the preamble... ==26970== Memcheck, a memory error detector ==26970== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al. ==26970== Using Valgrind-3.7.0.SVN and LibVEX; rerun with -h for copyright info ==26970== Command: echo hi ==26970== --26970-- Valgrind options: --26970-- -d --26970-- -v --26970-- Contents of /proc/version: --26970-- can't open /proc/version --26970-- Arch and hwcaps: AMD64, amd64-sse3-cx16 --26970-- Page sizes: currently 4096, max supported 4096 --26970-- Valgrind library directory: /Users/kumar/Desktop/valgrind-svn/lib/valgrind --26970:1:main ...finished the preamble --26970:1:main Initialise the tool part 2 (post_clo_init) --26970:1:main Initialise TT/TC --26970:1:main Initialise redirects --26970:1:mallocfr newSuperblock at 0x70000067C000 (pszB 1048544) owner VALGRIND/dinfo --26970:1:main Load initial debug info --26970-- /bin/echo (0x100000000) --26970-- reading syms from primary file (1 1) --26970-- /usr/lib/dyld (0x7fff5fc00000) --26970-- reading syms from primary file (6 1186) --26970:1:redir transfer ownership V -> C of 0x138049000 .. 0x138049fff --26970:1:main Initialise scheduler (phase 1) --26970:1:sched sched_init_phase1 --26970:1:main Tell tool about initial permissions --26970:1:main Initialise scheduler (phase 2) --26970:1:sched sched_init_phase2: tid_main=1, cls_end=0x7fff5fbfffff, cls_sz=8388608 --26970:1:main Finalise initial image --26970:1:main Initialise signal management --26970:1:main Load suppressions --26970-- Reading suppressions file: /Users/kumar/Desktop/valgrind-svn/lib/valgrind/default.supp --26970:1:main --26970:1:main --26970:1:aspacem <<< SHOW_SEGMENTS: Memory layout at client startup (30 segments, 2 segnames) --26970:1:aspacem ( 0) /bin/echo --26970:1:aspacem ( 1) /usr/lib/dyld --26970:1:aspacem 0: RSVN 0000000000-00ffffffff 4096m ----- SmFixed --26970:1:aspacem 1: file 0100000000-0100000fff 4096 r-x-- d=0xe000002 i=25866 o=4096 (0) --26970:1:aspacem 2: file 0100001000-0100001fff 4096 rw--- d=0xe000002 i=25866 o=8192 (0) --26970:1:aspacem 3: file 0100002000-0100003fff 8192 r---- d=0xe000002 i=25866 o=12288 (0) --26970:1:aspacem 4: 0100004000-01337fffff 823m --26970:1:aspacem 5: ANON 0133800000-0133ffffff 8388608 rw--- --26970:1:aspacem 6: 0134000000-0137ffffff 64m --26970:1:aspacem 7: ANON 0138000000-0138048fff 299008 r-x-- --26970:1:aspacem 8: anon 0138049000-0138049fff 4096 r-x-- --26970:1:aspacem 9: ANON 013804a000-0138259fff 2162688 r-x-- --26970:1:aspacem 10: ANON 013825a000-01391c4fff 15m rw--- --26970:1:aspacem 11: FILE 01391c5000-0139263fff 651264 r---- d=0x000 i=0 o=2486272 (-1) --26970:1:aspacem 12: 0139264000-6fffffffffff 114683g --26970:1:aspacem 13: RSVN 700000000000-700000000fff 4096 ----- SmFixed --26970:1:aspacem 14: ANON 700000001000-70000079bfff 7974912 rwx-- --26970:1:aspacem 15: 70000079c000-7fff5f3fffff 16381g --26970:1:aspacem 16: anon 7fff5f400000-7fff5fbfffff 8388608 rwx-- --26970:1:aspacem 17: file 7fff5fc00000-7fff5fc3bfff 245760 r-x-- d=0xe000002 i=634184 o=4096 (1) --26970:1:aspacem 18: file 7fff5fc3c000-7fff5fc40fff 20480 rw--- d=0xe000002 i=634184 o=249856 (1) --26970:1:aspacem 19: anon 7fff5fc41000-7fff5fc7afff 237568 rw--- --26970:1:aspacem 20: file 7fff5fc7b000-7fff5fc8efff 81920 r---- d=0xe000002 i=634184 o=270336 (1) --26970:1:aspacem 21: 7fff5fc8f000-7fff6fffffff 259m --26970:1:aspacem 22: FILE 7fff70000000-7fff711a8fff 17m rw--- d=0x000 i=0 o=152485888 (-1) --26970:1:aspacem 23: 7fff711a9000-7fff7fffffff 238m --26970:1:aspacem 24: ANON 7fff80000000-7fff8916bfff 145m r-x-- --26970:1:aspacem 25: FILE 7fff8916c000-7fff8b27efff 33m r---- d=0x000 i=0 o=171003904 (-1) --26970:1:aspacem 26: 7fff8b27f000-7fffffdfffff 1867m --26970:1:aspacem 27: file 7fffffe00000-7fffffffefff 2093056 r-x-- d=0x000 i=0 o=0 (-1) --26970:1:aspacem 28: 7ffffffff000-7fffffffffff 4096 --26970:1:aspacem 29: RSVN 800000000000-ffffffffffffffff 16383e ----- SmFixed --26970:1:aspacem >>> --26970:1:main --26970:1:main --26970:1:main Running thread 1 --26970:1:syswrap- entering VG_(main_thread_wrapper_NORETURN) --26970:1:aspacem allocated thread stack at 0x70000079c000 size 1064960 --26970:1:syswrap- run_a_thread_NORETURN(tid=1): pre-thread_wrapper --26970:1:syswrap- thread_wrapper(tid=1): entry --26970:1:transtab allocate sector 0 --26970:1:mallocfr newSuperblock at 0x700002532000 (pszB 65504) owner VALGRIND/ttaux --26970-- REDIR: 0x7fff5fc22fb0 (strcmp) redirected to 0x138049810 (???) --26970-- REDIR: 0x7fff5fc20693 (arc4random) redirected to 0x1380498ae (???) --26970-- REDIR: 0x7fff5fc22e90 (strlen) redirected to 0x1380497df (???) --26970-- REDIR: 0x7fff5fc22ee0 (strcpy) redirected to 0x13804982c (???) --26970-- REDIR: 0x7fff5fc2306f (strcat) redirected to 0x1380497f0 (???) --26970-- /Users/kumar/Desktop/valgrind-svn/lib/valgrind/vgpreload_core-amd64-darwin.so (0x100004000) --26970-- reading syms from primary file (3 135) --26970-- dSYM= /Users/kumar/Desktop/valgrind-svn/lib/valgrind/vgpreload_core-amd64-darwin.so.dSYM/Contents/Resources/DWARF/vgpreload_core-amd64-darwin.so --26970-- reading dwarf3 from dsyms file --26970-- /Users/kumar/Desktop/valgrind-svn/lib/valgrind/vgpreload_memcheck-amd64-darwin.so (0x10000f000) --26970-- reading syms from primary file (109 593) --26970-- dSYM= /Users/kumar/Desktop/valgrind-svn/lib/valgrind/vgpreload_memcheck-amd64-darwin.so.dSYM/Contents/Resources/DWARF/vgpreload_memcheck-amd64-darwin.so --26970-- reading dwarf3 from dsyms file ==26970== WARNING: new redirection conflicts with existing -- ignoring it --26970-- new: 0x7fff5fc1dcd0 (strlcat ) R-> 0x1000142e0 strlcat ==26970== WARNING: new redirection conflicts with existing -- ignoring it --26970-- new: 0x7fff5fc22ee0 (strcpy ) R-> 0x100014140 strcpy --26970-- REDIR: 0x7fff5fc227b0 (strncmp) redirected to 0x100012570 (strncmp) --26970-- REDIR: 0x7fff5fc23398 (memset) redirected to 0x100012890 (memset) --26970-- /usr/lib/libSystem.B.dylib (0x100024000) --26970-- reading syms from primary file (4604 3793) --26970:1:mallocfr newSuperblock at 0x70000254A000 (pszB 1048544) owner VALGRIND/dinfo --26970-- REDIR: 0x7fff5fc21a36 (strrchr) redirected to 0x100012290 (strrchr) --26970-- REDIR: 0x7fff5fc204b0 (strlcpy) redirected to 0x100013cc0 (strlcpy) --26970-- REDIR: 0x1000267dc (memcpy) redirected to 0x100013a60 (memcpy) --26970-- REDIR: 0x100025414 (memset) redirected to 0x100012810 (memset) --26970-- REDIR: 0x100026c8f (__memcpy_chk) redirected to 0x1000131f0 (__memcpy_chk) --26970-- REDIR: 0x1000271bc (malloc) redirected to 0x1000112c3 (malloc) --26970:1:mallocfr newSuperblock at 0x10027D000 (pszB 4194272) owner CLIENT/client --26970-- REDIR: 0x100028150 (strlen) redirected to 0x1000124f0 (strlen) --26970-- REDIR: 0x1000277e0 (strncmp) redirected to 0x100012510 (strncmp) --26970-- REDIR: 0x100028330 (strcmp) redirected to 0x1000125d0 (strcmp) hi --26970:1:syswrap- thread_wrapper(tid=1): done --26970:1:syswrap- run_a_thread_NORETURN(tid=1): post-thread_wrapper --26970:1:syswrap- run_a_thread_NORETURN(tid=1): last one standing --26970:1:main entering VG_(shutdown_actions_NORETURN) --26970:1:aspacem <<< SHOW_SEGMENTS: Memory layout at client shutdown (47 segments, 6 segnames) --26970:1:aspacem ( 0) /bin/echo --26970:1:aspacem ( 1) /usr/lib/dyld --26970:1:aspacem ( 2) /Users/kumar/Desktop/valgrind-svn/lib/valgrind/vgpreload_core-amd64-darwin.so --26970:1:aspacem ( 3) /Users/kumar/Desktop/valgrind-svn/lib/valgrind/vgpreload_memcheck-amd64-darwin.so --26970:1:aspacem ( 4) /usr/lib/libSystem.B.dylib --26970:1:aspacem ( 5) /usr/lib/system/libmathCommon.A.dylib --26970:1:aspacem 0: RSVN 0000000000-00ffffffff 4096m ----- SmFixed --26970:1:aspacem 1: file 0100000000-0100000fff 4096 r-xT- d=0xe000002 i=25866 o=4096 (0) --26970:1:aspacem 2: file 0100001000-0100001fff 4096 rw--- d=0xe000002 i=25866 o=8192 (0) --26970:1:aspacem 3: file 0100002000-0100003fff 8192 r---- d=0xe000002 i=25866 o=12288 (0) --26970:1:aspacem 4: file 0100004000-010000bfff 32768 r-xT- d=0xe000002 i=3943894 o=0 (2) --26970:1:aspacem 5: file 010000c000-010000cfff 4096 rw--- d=0xe000002 i=3943894 o=32768 (2) --26970:1:aspacem 6: file 010000d000-010000efff 8192 r---- d=0xe000002 i=3943894 o=36864 (2) --26970:1:aspacem 7: file 010000f000-010001cfff 57344 r-xT- d=0xe000002 i=3943930 o=0 (3) --26970:1:aspacem 8: file 010001d000-010001dfff 4096 rw--- d=0xe000002 i=3943930 o=57344 (3) --26970:1:aspacem 9: file 010001e000-0100023fff 24576 r---- d=0xe000002 i=3943930 o=61440 (3) --26970:1:aspacem 10: file 0100024000-01001e5fff 1843200 r-xT- d=0xe000002 i=3794163 o=4096 (4) --26970:1:aspacem 11: file 01001e6000-01001f7fff 73728 rw--- d=0xe000002 i=3794163 o=1847296 (4) --26970:1:aspacem 12: anon 01001f8000-0100208fff 69632 rw--- --26970:1:aspacem 13: file 0100209000-0100275fff 446464 r---- d=0xe000002 i=3794163 o=1921024 (4) --26970:1:aspacem 14: file 0100276000-010027afff 20480 r-x-- d=0xe000002 i=16179 o=4096 (5) --26970:1:aspacem 15: file 010027b000-010027cfff 8192 r---- d=0xe000002 i=16179 o=24576 (5) --26970:1:aspacem 16: anon 010027d000-010067cfff 4194304 rwx-H --26970:1:aspacem 17: 010067d000-01337fffff 817m --26970:1:aspacem 18: ANON 0133800000-0133ffffff 8388608 rw--- --26970:1:aspacem 19: 0134000000-0137ffffff 64m --26970:1:aspacem 20: ANON 0138000000-0138048fff 299008 r-x-- --26970:1:aspacem 21: anon 0138049000-0138049fff 4096 r-xT- --26970:1:aspacem 22: ANON 013804a000-0138259fff 2162688 r-x-- --26970:1:aspacem 23: ANON 013825a000-01391c4fff 15m rw--- --26970:1:aspacem 24: FILE 01391c5000-0139263fff 651264 r---- d=0x000 i=0 o=2486272 (-1) --26970:1:aspacem 25: 0139264000-6fffffffffff 114683g --26970:1:aspacem 26: RSVN 700000000000-700000000fff 4096 ----- SmFixed --26970:1:aspacem 27: ANON 700000001000-70000079bfff 7974912 rwx-- --26970:1:aspacem 28: ANON 70000079c000-70000079dfff 8192 ----- --26970:1:aspacem 29: ANON 70000079e000-70000089dfff 1048576 rwx-- --26970:1:aspacem 30: ANON 70000089e000-70000089ffff 8192 ----- --26970:1:aspacem 31: ANON 7000008a0000-700002659fff 29m rwx-- --26970:1:aspacem 32: 70000265a000-7fff5f3fffff 16381g --26970:1:aspacem 33: anon 7fff5f400000-7fff5fbfffff 8388608 rwx-- --26970:1:aspacem 34: file 7fff5fc00000-7fff5fc3bfff 245760 r-xT- d=0xe000002 i=634184 o=4096 (1) --26970:1:aspacem 35: file 7fff5fc3c000-7fff5fc40fff 20480 rw--- d=0xe000002 i=634184 o=249856 (1) --26970:1:aspacem 36: anon 7fff5fc41000-7fff5fc7afff 237568 rw--- --26970:1:aspacem 37: file 7fff5fc7b000-7fff5fc8efff 81920 r---- d=0xe000002 i=634184 o=270336 (1) --26970:1:aspacem 38: 7fff5fc8f000-7fff6fffffff 259m --26970:1:aspacem 39: FILE 7fff70000000-7fff711a8fff 17m rw--- d=0x000 i=0 o=152485888 (-1) --26970:1:aspacem 40: 7fff711a9000-7fff7fffffff 238m --26970:1:aspacem 41: ANON 7fff80000000-7fff8916bfff 145m r-x-- --26970:1:aspacem 42: FILE 7fff8916c000-7fff8b27efff 33m r---- d=0x000 i=0 o=171003904 (-1) --26970:1:aspacem 43: 7fff8b27f000-7fffffdfffff 1867m --26970:1:aspacem 44: file 7fffffe00000-7fffffffefff 2093056 r-xT- d=0x000 i=0 o=0 (-1) --26970:1:aspacem 45: 7ffffffff000-7fffffffffff 4096 --26970:1:aspacem 46: RSVN 800000000000-ffffffffffffffff 16383e ----- SmFixed --26970:1:aspacem >>> ==26970== ==26970== HEAP SUMMARY: ==26970== in use at exit: 120 bytes in 2 blocks ==26970== total heap usage: 2 allocs, 0 frees, 120 bytes allocated ==26970== ==26970== Searching for pointers to 2 not-freed blocks ==26970== Checked 414,824 bytes ==26970== ==26970== LEAK SUMMARY: ==26970== definitely lost: 32 bytes in 1 blocks ==26970== indirectly lost: 0 bytes in 0 blocks ==26970== possibly lost: 0 bytes in 0 blocks ==26970== still reachable: 88 bytes in 1 blocks ==26970== suppressed: 0 bytes in 0 blocks ==26970== Rerun with --leak-check=full to see details of leaked memory ==26970== ==26970== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) ==26970== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) --26970:1:core_os VG_(terminate_NORETURN)(tid=1)
Created attachment 56211 [details] valgrind --leak-check=full --dsymutil=yes --leak-check=full --show-reachable=yes -v ./main Hi Prashant, please allow me to hijack your bug report. I am seeing the exact same issue on my Mac OS X 10.6 x86_64 (w/ 64bit Kernel) machine. Tested with valgrind 3.6.0 so far. Additionally, it is not dependent on the compiler version, as I'm seeing it with everyone I've tried so far (Apple GCC 4.2, MacPorts GCC 4.4 and MacPorts GCC 4.5.) Even a simple program like int main (void) { return (0); } will trigger this "bug" (please read below for an explanation of why I hesitate to call this a bug.) A sample valgrind output is attached and should help to clear things up. Basically, it may well be a mem leak in libSystem (OS X' libc), or dyld. Given the bugs I've seen on Apple systems, I'd not be that surprised... then again, OS X support in valgrind is still pretty new and this may indeed be a false positive which has to be looked upon. Unfortunately I'm far from being an expert on this stuff, so I hope some dev can figure it out or at least give a helpful hand. :) This whole stuff is not critical, but it may actually disturb other users or indeed confuse them for good. Best regards, Mihai
Created attachment 57383 [details] ./valgrind -d -v echo hi (with some system info)
@Mihai, I welcome your hijacking of my ticket :) I was indeed hoping this to be a false positive. I don't know much about Macs, just recently jumped on the bandwagon, and I just use them pretending they are Unix-type machines. The valgrind testers were testing on Mac OS X 10.5, correct? And if they didn't find any problems on that version of the platform, then at least the problem could be pinpointed as some change between the two versions. Which brings me to the question, where should I go to push this upstream for some input? lists.apple.com? I agree (and am thankful) this is not of critical priority, but I'd be curious to see this resolved (even though I'm sure the problem is beyond my understanding).
Hello, It is a know issue that Valgrind on OS X always reports some memory "still reachable". This is not specific to OS X 10.5, and still present through OS X 10.10 (and OS X 10.11 pre release) with latest Valgrind SVN trunk. For now, please don't report these upstream to Apple. These may be false positives, and we'd need to undertake more work to ensure the reports are valid. Resolving these reports are a "nice to have" rather than a pressing bug that must be fixed. Per the Valgrind documentation: http://valgrind.org/docs/manual/faq.html * "still reachable" means your program is probably ok -- it didn't free some memory it could have. This is quite common and often reasonable. Don't use --show-reachable=yes if you don't want to see these reports.
*** Bug 354428 has been marked as a duplicate of this bug. ***