[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory leak in getsysstats.c

From: wmglo
Subject: Re: Memory leak in getsysstats.c
Date: 22 Sep 2003 13:26:43 -0000


> I'm currently using 7.2, so at a guess this may have been fixed. Using 
> Insure++
> to check for leaks, I came across the following stack trace :-
>          6 bytes 1 chunk allocated at strdup.c, 43
>                           malloc()  (interface)
>                         __strdup()  strdup.c, 43
>                    get_proc_path()  ../sysdeps/unix/sysv/linux/getsysstats.c, 
> 78

I believe this has been fixed in glibc-2.3.2, because the pointer in
question was added to the __libc_freeres section, which is freed at
program exit.

>  if (compare_and_swap ((long int *) &mount_proc, (long int) 0,
>                        (long int) copy_result) == 0)
>    /* Replacing the value failed.  This means another thread was
>       faster and we don't need the copy anymore.  */
>    free (copy_result);
> Basically if the expression "compare_and_swap ((long int *) &mount_proc, 
> (long int) 0,
>  (long int) copy_result)" equates to anything other zero ( can it ever ? ) 
> you'll get a leak.

Only if the compare_and_swap with the value 0 succeeded (which can
only happen once, hence you get only "1 chunk" above!) there the chunk
in question isn't freed, so the "leak" was absolutely harmless.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]