Bug 217236 - Mac OS X: pthread_cond_wait reports still reachable leaked memory
Summary: Mac OS X: pthread_cond_wait reports still reachable leaked memory
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.6 SVN
Platform: Unlisted Binaries macOS
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-03 18:10 UTC by Evan Jones
Modified: 2015-05-07 13:53 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
test program that causes the valgrind warning (1.08 KB, application/octet-stream)
2009-12-03 18:10 UTC, Evan Jones
Details
corrected test program that causes the warning (1.19 KB, application/octet-stream)
2009-12-03 18:14 UTC, Evan Jones
Details
add a suppression for new_sem_from_pool (502 bytes, patch)
2009-12-03 18:16 UTC, Evan Jones
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Evan Jones 2009-12-03 18:10:22 UTC
Created attachment 38801 [details]
test program that causes the valgrind warning

On Mac OS X, pthread_cond_wait ends up calling new_sem_from_pool, which allocates a pool of semaphore objects that gets reused. This causes Valgrind to report a "still reachable" warning for this memory that is not leaked. Occasionally for more complex programs, this reports a full-blown "definitely lost" error. The attached program causes the SVN version of Valgrind to report this warning. The attached patch to the suppressions suppresses it.

The source of the new_sem_from_pool function can be found:

http://www.opensource.apple.com/source/Libc/Libc-583/pthreads/pthread.c
Comment 1 Evan Jones 2009-12-03 18:14:47 UTC
Created attachment 38802 [details]
corrected test program that causes the warning
Comment 2 Evan Jones 2009-12-03 18:16:36 UTC
Created attachment 38803 [details]
add a suppression for new_sem_from_pool
Comment 3 Evan Jones 2009-12-03 18:17:07 UTC
The original warning is:

=23593== 64 bytes in 1 blocks are still reachable in loss record 2 of 3
==23593==    at 0x15416: malloc (vg_replace_malloc.c:195)
==23593==    by 0x17225: realloc (vg_replace_malloc.c:476)
==23593==    by 0x229507: new_sem_from_pool (in /usr/lib/libSystem.B.dylib)
==23593==    by 0x2291A5: _pthread_cond_wait (in /usr/lib/libSystem.B.dylib)
==23593==    by 0x228DCC: pthread_cond_wait$UNIX2003 (in /usr/lib/libSystem.B.dylib)
==23593==    by 0x1E4A: main (in ./test)


The original suppression is:

{
   darwin-still-reachable-4
   Memcheck:Leak
   fun:malloc
   fun:realloc
   fun:new_sem_from_pool
   fun:_pthread_cond_wait
   fun:pthread_cond_wait$UNIX2003
   fun:main
}
Comment 4 Rhys Kidd 2015-05-07 13:21:21 UTC
Resolved in r15190 for OS X 10.8.