* 'pthread_mutex_destroy' memory leak report
@ 1999-09-07 9:31 Milan Gardian
1999-09-07 20:02 ` Ross Johnson
0 siblings, 1 reply; 2+ messages in thread
From: Milan Gardian @ 1999-09-07 9:31 UTC (permalink / raw)
To: pthreads-win32
Dear pthreads colleagues,
Purify has recently reported to me a memory leak that originated in my
pthread mutex adapter class. I have investigated deeper into the code and
here are my findings:
===
file: pthreads_dir/mutex.c
line: 91
func: pthread_mutex_init
mx = (pthread_mutex_t) calloc(1, sizeof(*mx));
---
file: pthreads_dir/mutex.c
line: ?
func: pthread_mutex_destroy
No corresponding free (to the calloc above).
===
My advice is to insert 'free(mx)' call into 'pthread_mutex_destroy' function
before returning status to the caller (if mx has reasonable value, of
course) as follows:
===
file: pthreads_dir/mutex.c
line: 197 - 204
func: pthread_mutex_destroy
if (result == 0)
{
mx->mutex = 0;
free (mx);
*mutex = NULL;
}
return(result);
===
(Or am I missing something?)
Hope this helps,
Best regards,
Milan G.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: 'pthread_mutex_destroy' memory leak report
1999-09-07 9:31 'pthread_mutex_destroy' memory leak report Milan Gardian
@ 1999-09-07 20:02 ` Ross Johnson
0 siblings, 0 replies; 2+ messages in thread
From: Ross Johnson @ 1999-09-07 20:02 UTC (permalink / raw)
To: Milan Gardian; +Cc: pthreads-win32
On Tue, 7 Sep 1999, Milan Gardian wrote:
> Dear pthreads colleagues,
>
> Purify has recently reported to me a memory leak that originated in my
> pthread mutex adapter class. I have investigated deeper into the code and
> here are my findings:
>
[snip]
>
> My advice is to insert 'free(mx)' call into 'pthread_mutex_destroy' function
> before returning status to the caller (if mx has reasonable value, of
> course) as follows:
>
> ===
> file: pthreads_dir/mutex.c
> line: 197 - 204
> func: pthread_mutex_destroy
>
> if (result == 0)
> {
> mx->mutex = 0;
> free (mx);
> *mutex = NULL;
> }
>
> return(result);
> ===
>
Hi Milan,
Your fix will be in the next snapshot.
Thanks.
Ross
+----------------------+---+
| Ross Johnson | | E-Mail: rpj@ise.canberra.edu.au
| Info Sciences and Eng|___|
| University of Canberra | FAX: +61 6 2015227
| PO Box 1 |
| Belconnen ACT 2616 | WWW: http://willow.canberra.edu.au/~rpj/
| AUSTRALIA |
+--------------------------+
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-09-07 20:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-07 9:31 'pthread_mutex_destroy' memory leak report Milan Gardian
1999-09-07 20:02 ` Ross Johnson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).