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


  • 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);
  TempCompany: TCompany;
  if Assigned(AStrList) then
    AStrList.AddObject(FDefaultCompany.Name, TObject(FDefaultCompany.ID));
    for TCollectionItem(TempCompany) in FCompanies do
      AStrList.AddObject(TempCompany.Name, TObject(TempCompany.ID));

I call this as follows:

Code: [Select]
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


  • Hero Member
  • *****
  • Posts: 8244
  • 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
  Use FPC trunk;


TinyPortal © 2005-2018