Re: [fpc-devel] Memory leak on BeginThread() when RTL compiled with -O2

2021-05-25 Thread Jonas Maebe via fpc-devel
On 25/05/2021 18:08, Yuriy Sydorov via fpc-devel wrote: > I've double checked this and the mode change seems to work fine. > The source of the issue is that specifying -Mfpc enables inlining which > triggers a bug in the Windows RTL. > I've fixed the bug in r49400. Thanks! Jonas

Re: [fpc-devel] Memory leak on BeginThread() when RTL compiled with -O2

2021-05-25 Thread Yuriy Sydorov via fpc-devel
On 24.05.2021 23:16, Jonas Maebe via fpc-devel wrote: On 24/05/2021 12:18, Yuriy Sydorov via fpc-devel wrote: You can't first pass the -Mdelphi switch and then override it with -Mfpc. -Mdelphi implicitly enables lot of other compiler options which are not reverted by -Mfpc. That feels like a b

Re: [fpc-devel] Memory leak on BeginThread() when RTL compiled with -O2

2021-05-24 Thread Jonas Maebe via fpc-devel
On 24/05/2021 12:18, Yuriy Sydorov via fpc-devel wrote: > You can't first pass the -Mdelphi switch and then override it with > -Mfpc. -Mdelphi implicitly enables lot of other compiler options which > are not reverted by -Mfpc. That feels like a bug. Jonas

[fpc-devel] Memory leak on BeginThread() when RTL compiled with -O2

2021-05-24 Thread NetSpirit via fpc-devel
> Hello, > > You have not read closely what I wrote before: Sorry, earlier I try your hint - and result was bad. Perhaps I did something wrong. But I repeat it now - and it is working. Thank you again. Finally my working build script look like this: set UNITS_PATH=.\packages\* set UNITS_PATH=.\

Re: [fpc-devel] Memory leak on BeginThread() when RTL compiled with -O2

2021-05-24 Thread Yuriy Sydorov via fpc-devel
Hello, You have not read closely what I wrote before: "When compiling RTL you should disable reading of options from fpc.cfg using the -n switch. When compiling the system unit use the -Us switch. Additionally specify only CPU/Target and optimization options -O. No other options are required fo

[fpc-devel] Memory leak on BeginThread() when RTL compiled with -O2

2021-05-24 Thread NetSpirit via fpc-devel
Unfortunately I tried it and this doesn't work. Problem only with 'sysinitpas.pp' unit. He is not depends on other RTL units, but linked into final executable by compiler. I suppose, compiler itself depends on internal layout of this unit. And a solution is to compile 'sysinitpas.pp' with the same

[fpc-devel] Memory leak on BeginThread() when RTL compiled with -O2

2021-05-21 Thread NetSpirit via fpc-devel
Thank you, i will try this. > I've take a look at you RTL compile script and found the mess with the compiler options. > > When compiling RTL you should disable reading of options from fpc.cfg using the -n switch. > When compiling the system unit use the -Us switch. > Additionally specify only CPU

Re: [fpc-devel] Memory leak on BeginThread() when RTL compiled with -O2

2021-05-20 Thread Yuriy Sydorov via fpc-devel
Hello, I've take a look at you RTL compile script and found the mess with the compiler options. When compiling RTL you should disable reading of options from fpc.cfg using the -n switch. When compiling the system unit use the -Us switch. Additionally specify only CPU/Target and optimization op

[fpc-devel] Memory leak on BeginThread() when RTL compiled with -O2

2021-05-20 Thread NetSpirit via fpc-devel
RTL not modified. Just recompilation of 'sysinitpas.pp' unit with some options causes problem. Here is another test project that uses your current official FPC installation with unmodified RTL: http://dl.free.fr/ePtkQwgJJ Test project contains source of 'sysinitpas.pp' (and required 'sysinit.inc'

Re: [fpc-devel] Memory leak on BeginThread() when RTL compiled with -O2

2021-05-20 Thread Yuriy Sydorov via fpc-devel
Hello, Your test program runs fine when compiled with FPC 3.2.0 using the official RTL compiled with -O2. No memory leak. I suppose the issue is caused by your modifications to RTL. -O2 (regvars) just triggers the problem in the modified RTL code which is hidden when regvars are disabled. You

[fpc-devel] Memory leak on BeginThread() when RTL compiled with -O2

2021-05-20 Thread NetSpirit via fpc-devel
You can simply compile this file by yourself using your existing FPC installation. 1) Get 'rtl\win32\sysinitpas.pp' and 'rtl\win32\sysinit.inc' from repository or sources archive. 2) Create build script ('compile.bat'): REM Change this path's to your FPC installation, e.g.: set FPC_DIR=c:\FPC set

Re: [fpc-devel] Memory leak on BeginThread() when RTL compiled with -O2

2021-05-20 Thread J. Gareth Moreton via fpc-devel
Hmmm, I've seen regvar problems before.  Can you provide the assembly dumps of that file under -O2 and -O2 -OoNOREGVAR respectively? It might reveal something. Gareth aka. Kit On 20/05/2021 09:07, NetSpirit via fpc-devel wrote: Answer for my previous message (https://lists.freepascal.org/pipe

[fpc-devel] Memory leak on BeginThread() when RTL compiled with -O2

2021-05-20 Thread NetSpirit via fpc-devel
Answer for my previous message (https://lists.freepascal.org/pipermail/fpc-devel/2021-January/043512.html). Memory leak happens when unit 'rtl\win32\sysinitpas.pp' compiled with "-O2" or higher. To eliminate this bug add "-O-" or "-OoNOREGVAR" to command-line when compile this unit. This disables

[fpc-devel] Memory leak on BeginThread() when RTL compiled with -O2

2021-01-11 Thread NetSpirit via fpc-devel
I am using custom build of minimal FPC RTL and found possible bug. When unit 'system' (or some other?) compiled using -O2 (or higher) option in 'fpc.cfg', then application, compiled using this unit, increase memory usage every time BeginThread() function is called. This appears on FPC 3.2.0 and not