Since you mentioned cprt0, you could try checking the order of initialization of libc and libgcc. This may have something to do with it, see also http://bugs.freepascal.org/view.php?id=14265

Peter


On Wed, 05 Aug 2009 07:19:56 -0500, Jonas Maebe <[email protected]> wrote:


On 05 Aug 2009, at 13:55, Wimpie Nortje wrote:

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

This invalid free is probably the reason for the memory leak.

It even happens for this program:

{$linklib c}
begin
end.

There is probably some error in FPC's startup code (the code in fpc/ rtl/linux/i386/cprt0.as) which doesn't initialise some libc pointer. You should indeed report a bug about this.

To Graeme and Michael: heaptrc is useless/irrelevant to analyse memory leaks reported inside libc. Such errors can always be due to wrong usage of the C library from within FPC code.


Jonas
_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel



--
|***********************************************|
|                                               |
|  Peter Popov,                                 |
|                                               |
|  608L Blocker Bldg.                           |
|  Institute for Scientific Computation,        |
|  Texas A&M University                         |
|  College Station, Texas 77843-3404            |
|-----------------------------------------------|
|  Phone: +1 (979) 458-4644,                    |
|  Fax: +1 (979) 845-5827                       |
|                                               |
|***********************************************|
_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to