Free nonexistent stringlist error? lazarus / 31-LCL ---------------------------------------------------------------------- Ruptor · 2013-02-07 00:49 It appears that if a stringlist that has not been loaded is freed the system gives an exception error SIGSEGV. I read about debugger problems but it happens using the exe file. Is this a compiler problem or is to be expected and down to the user not to do it? I am using windows XP, fpc 2.6.1, Lazarus 1.1 r40186 ---------------------------------------------------------------------- taazz · 2013-02-07 00:53 show us some code to better understand your position "string list that has not been loaded" has at least 2 different interpretations 1) the object has been created but no data has been inserted in it. 2) The object has not been created. in the 1st case freeing the object should work in the second it should not. ---------------------------------------------------------------------- Ruptor · 2013-02-07 01:33 Here is what is left of the procedure after I chopped everything out of it to find the problem. Code: [Select]procedure TForm1.Button2Click(Sender: TObject); var   Str: TStringList;   Price: string;   PriceStr: Packed Array[1..300] of char;   cafl: array[0..1000] of Integer;   ask,bid,freq,y: Real;   code,ifreq,x: Integer;   asc,i,j,timsec: LongInt;   morech,opened:boolean; begin   i:=0;   while i<1000 do   begin     cafl[i]:=0;     i:=i+1;   end;   Str.Free; end; Commenting out the STR.Free statement stops the exception. ---------------------------------------------------------------------- typo · 2013-02-07 02:00 Quote from: Ruptor on February 07, 2013, 02:33:20 amCommenting out the STR.Free statement stops the exception. Of course. You can not Free a non-created object. ---------------------------------------------------------------------- Ruptor · 2013-02-07 02:40 Why doesn't the compiler say something? It warns about uninitialised variables so why not objects? ---------------------------------------------------------------------- Martin_fr · 2013-02-07 02:55 I just copied your code. And I get all of the below messages. Starts with a warning about Str. Code: [Select]unit1.pas(48,3) Warning: Local variable "Str" does not seem to be initialized unit1.pas(34,3) Note: Local variable "Price" not used unit1.pas(35,3) Note: Local variable "PriceStr" not used unit1.pas(36,3) Note: Local variable "cafl" is assigned but never used unit1.pas(37,3) Note: Local variable "ask" not used unit1.pas(37,7) Note: Local variable "bid" not used unit1.pas(37,11) Note: Local variable "freq" not used unit1.pas(37,16) Note: Local variable "y" not used unit1.pas(38,3) Note: Local variable "code" not used unit1.pas(38,8) Note: Local variable "ifreq" not used unit1.pas(38,14) Note: Local variable "x" not used unit1.pas(39,3) Note: Local variable "asc" not used unit1.pas(39,9) Note: Local variable "j" not used unit1.pas(39,11) Note: Local variable "timsec" not used unit1.pas(40,3) Note: Local variable "morech" not used unit1.pas(40,10) Note: Local variable "opened" not used ---------------------------------------------------------------------- Ruptor · 2013-02-07 03:09 Yes you are right I missed the new message but with the whole procedure in place the message doesn't occur. Here is the whole routine that I am messing around with. Code: [Select]procedure TForm1.Button2Click(Sender: TObject); var   Str: TStringList;   Price: string;   PriceStr: Packed Array[1..300] of char;   cafl: array[0..1000] of Integer;   ask,bid,freq,y: Real;   code,ifreq,x: Integer;   asc,i,j,timsec: LongInt;   morech,opened:boolean; begin   i:=0; //  while i-1 then     begin       ProgressBar1.Min:=0;       ProgressBar1.Max:=Str.Count;       ProgressBar1.Step:=1;       ProgressBar1.StepBy(1);       Edit2.text:=inttostr(Str.Count);       BidLine.clear;       i:=0;       while i=$30) and (asc <=$39) or (asc =$2E) then           begin             Price:=Price+PriceStr[j];             j:=j+1;           end           else             begin               if asc =$2C then               begin                 val(Price,freq,code);                 ifreq:=round(freq);                 cafl[ifreq]:=cafl[ifreq]+1;                 Price:='';                 j:=j+1;               end               else morech:=false;             end;           end;         end;         ProgressBar1.StepIt;         i:=i+1;       end;       ifreq:=0;       while ifreq