[fpc-devel] Possible memory leak in cthread.

Michael Van Canneyt michael at freepascal.org
Wed Aug 5 14:03:12 CEST 2009



On Wed, 5 Aug 2009, Wimpie Nortje wrote:

> Hi everybody,
>
> The program:
> program memleak;
>
> {$mode objfpc}{$H+}
>
> uses
> cthreads;
>
> begin
> end.
>
>
>
> If I run the program using valgrind I get the following output:
> ==1944==    Invalid free() / delete / delete[] 
> ==1944==    at 0x4025DFA: free (vg_replace_malloc.c:323) 
> ==1944==    by 0x4171664: (within /lib/tls/i686/cmov/libc-2.9.so)
> ==1944==    by 0x4020422: _vgnU_freeres (vg_preloaded.c:60)
> ==1944==    by 0x40E5B23: _Exit (in /lib/tls/i686/cmov/libc-2.9.so)
> ==1944==    by 0x405C77C: (below main) (in /lib/tls/i686/cmov/libc-2.9.so)
> ==1944==  Address 0xffffffff is not stack'd, malloc'd or (recently) free'd
>
> ==1944== LEAK SUMMARY:
> ==1944==    definitely lost: 0 bytes in 0 blocks.
> ==1944==      possibly lost: 0 bytes in 0 blocks.
> ==1944==    still reachable: 1,094 bytes in 5 blocks.
> ==1944==         suppressed: 0 bytes in 0 blocks.
>
> I use Kubuntu 9.04, fpc 2.2.4
>
> Can I log this as a bug?

I doubt it, since the error seems to occur in the C library.
If you run with heaptrc, you should see that FPC does no allocations which it didn't free:

gru: >fpc -glh testh.pp
gru: >./testh
Heap dump by heaptrc unit
4 memory blocks allocated : 1023/1040
4 memory blocks freed     : 1023/1040
0 unfreed memory blocks : 0
True heap size : 360448
True free heap : 360448
gru: >

Michael.



More information about the fpc-devel mailing list