Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Apr 2005 09:20:05 GMT
From:      Kimmo Mustonen <tzimmo@rommon.com>
To:        freebsd-threads@FreeBSD.org
Subject:   Re: threads/79526: A memory leak in pthread_rwlock_init()
Message-ID:  <200504050920.j359K5l0069486@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR threads/79526; it has been noted by GNATS.

From: Kimmo Mustonen <tzimmo@rommon.com>
To: Craig Rodrigues <rodrigc@crodrigues.org>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: threads/79526: A memory leak in pthread_rwlock_init()
Date: Tue, 5 Apr 2005 12:14:17 +0300 (EEST)

 On Mon, 4 Apr 2005, Craig Rodrigues wrote:
 
 > Can you try this patch?
 > prwlock was being allocated by malloc inside pthread_rwlock_init(),
 > but never freed.
 > 				*rwlock = prwlock;
 > +				free(prwlock);
 
 First, this patch is broken. It sets the pointer to a datastructure but 
 frees the contents of the structure immediately after that, later causing 
 referencing to deallocated memory and crashing.
 
 The valgrind version did not crash but still leaked memory after this 
 (broken) patch. I didn't realise valgrind has its own pthread library. 
 Thus, the problem is most probably in the valgrind implementation of 
 pthread library and the actual pthread library does not leak. So I don't 
 think there's a need for a patch in pthread.
 
 I hope this problem will disappear when the new valgrind using native 
 pthread library is ported to FreeBSD.
 
 Regards,
 Kimmo Mustonen



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200504050920.j359K5l0069486>