Recent

Author Topic: SIGSEGV with Optimization level 2 enabled  (Read 2519 times)

ggallo

  • New Member
  • *
  • Posts: 13
SIGSEGV with Optimization level 2 enabled
« on: August 18, 2014, 09:58:19 am »
Hi All!

I have a strange problem what I can't resolve. When I enable level 2 optimization, my program exits with SIGSEGV, with level 1 or 0 there is no problem.

The code I'm using that causes the SIGSEGV:

Code: [Select]
procedure TAppUser.CompaniesAsStringList(AStrList: TStrings);
var
  TempCompany: TCompany;
begin
  if Assigned(AStrList) then
  begin
    AStrList.Clear;
    AStrList.AddObject(FDefaultCompany.Name, TObject(FDefaultCompany.ID));
    for TCollectionItem(TempCompany) in FCompanies do
      AStrList.AddObject(TempCompany.Name, TObject(TempCompany.ID));
  end;
end;

I call this as follows:

Code: [Select]
FUser.CompaniesAsStringList(cbFirm.Items);
The cbFirms is a TComboBox, the items filled with company names the current user can choose from.
With optimization level 0 or 1 there are no problems. With level 2 or 3, when AStrList.Clear ran, the AStrList canged to Nil, so next call causes SIGSEGV.

I can't figure out why this happens or how can I resolve it.

I'm using Lazarus 1.2.2 with FPC 2.6.4, on Windows 7 Home Premium 64 bit (Core i3-3220, 8GB). The same error occurs on (same host machine, but in a VirtualBox session) openSuSE 12.3 - 32 bit, same Lazarus and FPC.
Windows 7 64 bit | openSuSE 12.3 32 bit
Lazarus 1.2.4 | fpc 2.6.4 | Win32/64 | Linux gtk2

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: SIGSEGV with Optimization level 2 enabled
« Reply #1 on: August 18, 2014, 11:31:11 am »
Code: [Select]
Test with FPC trunk;
if the issue still appears then
  Report to the bug tracker
else
  Use FPC trunk;

 

TinyPortal © 2005-2018