threads/79526: A memory leak in pthread_rwlock_init()

Craig Rodrigues rodrigc at crodrigues.org
Mon Apr 4 13:30:11 PDT 2005


The following reply was made to PR threads/79526; it has been noted by GNATS.

From: Craig Rodrigues <rodrigc at crodrigues.org>
To: Kimmo Mustonen <tzimmo at rommon.com>
Cc: FreeBSD-gnats-submit at freebsd.org
Subject: Re: threads/79526: A memory leak in pthread_rwlock_init()
Date: Mon, 4 Apr 2005 16:25:40 -0400

 On Mon, Apr 04, 2005 at 03:36:02PM +0300, Kimmo Mustonen wrote:
 >         Haven't looked at the sources, but probably easy to fix.
 >         I suppose pthread_rwlock_destroy() just does not free all the
 >         resources pthread_rwlock_init() allocates.
 
 
 Can you try this patch?
 prwlock was being allocated by malloc inside pthread_rwlock_init(),
 but never freed.
 
 
 --- lib/libpthread/thread/thr_rwlock.c.orig	Mon Apr  4 16:22:16 2005
 +++ lib/libpthread/thread/thr_rwlock.c	Mon Apr  4 16:23:26 2005
 @@ -131,6 +131,7 @@
  				prwlock->blocked_writers = 0;
  
  				*rwlock = prwlock;
 +				free(prwlock);
  			}
  		}
  	}
 
 
 -- 
 Craig Rodrigues        
 rodrigc at crodrigues.org


More information about the freebsd-threads mailing list