[fpc-devel] crash with -gt -O2 in trunk

Martin fpc at mfriebe.de
Sat Jun 5 19:13:09 CEST 2010


On 05/06/2010 17:44, Jonas Maebe wrote:
> On 05 Jun 2010, at 18:09, Martin wrote:
>
>    
>> Ok, I should say first, I do not know if it is fpc, or lazarus. At the moment I guess fpc.
>>
>> It only happens in trunk (15366, also seen with earlier trunk) / rel 2.4.0 seems to be not affected
>> It only happens in combination of -O2 and -gt together.
>>
>> Compiled lazarus with:   -gh -gt -g -gl  -gw -godwarfsets  -O2
>>      
> What about the RTL?
>    

* compiler was build using

..\trunk_build\make.exe clean distclean
..\trunk_build\make.exe rtl packages  compiler   LINKSMART=1  
CREATESMART=1  OPTIMIZE=1  OPT="-O3 -Or -CpPENTIUMM -OpPENTIUMM"  
TARGET_EXAMPLES=NO FPC=c:\FPC\SVN\ppc386_2_4_0.exe
..\trunk_build\make.exe install  INSTALL_PREFIX=c:\FPC\strunc\  
COPYTREE=echo UPXPROG=echo

* RTL was build
..\trunk_build\make.exe rtl_clean packages_clean
..\trunk_build\make.exe rtl packages    LINKSMART=1  CREATESMART=1  
DEBUG=1 OPTIMIZE=0  OPT="-gl -gw -godwarfsets -O1" 
FPC=c:\FPC\strunc\bin\i386-win32\fpc.exe   TARGET_EXAMPLES=NO
..\trunk_build\make.exe rtl_install packages_install 
INSTALL_PREFIX=c:\FPC\strunc\  COPYTREE=echo UPXPROG=echo  
FPC=c:\FPC\strunc\bin\i386-win32\fpc.exe

No -gt here.

Interesting too. The RTL was not modified between the builds => so the 
crash depended solely on the flags used to build lazarus/LCL




> One common pitfall with -gt: it not only trashes local variables, but also "out" parameters. It happens from time to time that people expect "out" parameters to be unmodified if the callee doesn't modify it. Another problem is if you have something like do_assignment(const fromrec: trecord; out torec: trecord) and you call it like do_assignment(rec1,rec1). Since the torec parameter will be trashed on procedure entry and since the fromrec parameter may be passed by reference, the assigned value may become the trashed one instead of the original one.
>
> There is at least one place in the rtl where this can happen in case it is compiled with -gt (the helper used when assigning a shortstring to another one), so in general I would recommend against compiling the rtl with -gt.
>
>
> Jonas_______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
>    




More information about the fpc-devel mailing list