Tstringlist Segfault lazarus / 32-Linux ---------------------------------------------------------------------- liewald · 2017-09-26 09:14 Lazarus 1.6.4 rUnknown FPC 3.0.0 x86_64-linux-gtk 2 Opensuse Leap 42.3 I'm suddenly getting a segfault when assigning a value to a stringlist, I'm not doing anything particularity complex initialising stringlist with for I := 0 to indata.count-1 do   begin     outstring := ' ';     outdata.Add(outstring);   end; and then assigning a value  using outdata.strings[offset] := outstring;  in another procedure where offset is passed into the procedure from a loop outdata.strings[0]'th entry is replaced fine but fails on outdata.strings[1] entry fails with a segfault outdata.count is returning the correct number of strings available within the stringlist. Driving me nuts the reason for doing it this way is to create an output object for running the process multithreaded, was working perfectly but suddenly crashed out and now I cant get it to run ( ?? linux update)) Dave ---------------------------------------------------------------------- marcov · 2017-09-26 09:40 You are showing only partial code, so we can't see anything, how do you .create the class? ---------------------------------------------------------------------- liewald · 2017-09-26 09:43 yup Sorry there is masses of code involved. as I mentioned everything was running fine then collapsed with no real code change procedure TForm1.FormCreate(Sender: TObject); begin   indata := tstringlist.create;   outdata := tstringlist.Create;   dosepositions := tthreadstringlist.create; end; procedure TForm1.FormDestroy(Sender: TObject); begin   indata.destroy;   outdata.destroy;   dosepositions.destroy; end;  Dave ---------------------------------------------------------------------- liewald · 2017-09-26 09:45 here's the procedure procedure TForm1.process_string(Index: integer); const delims = [#9]; var I,hpos: integer;      datastring, outstring : ansistring ;      doseoffsets : array of integer;      offset : integer; begin   offset := index;   outstring := '';   datastring := indata[index];   setlength(doseoffsets,dosepositions.Count-1);   hpos := wordposition(3,datastring,delims);   for i := 0 to dosepositions.count -1 do   doseoffsets :=  hpos + ((strtoint(dosepositions)) * 6);   outstring := extractword(1,datastring,delims) + #9 + extractword(2,datastring,delims) ;   for i := 0 to dosepositions.count-1 do   begin     outstring := outstring + #9 + copy(datastring,doseoffsets,5);   end;   outdata.strings[offset] := outstring; end; ---------------------------------------------------------------------- rvk · 2017-09-26 09:55 Please always put code between the code-tags [code]your code[/code] (otherwise it will not be formatted correctly and parts will be invisible, like [i] which is italic-font switch) Or select your code and press the #-button above the editor (it will insert [code=pascal]yourcode[/code] automatically). I've done it in your quote below. Quote from: liewald on September 26, 2017, 11:45:32 amhere's the procedure Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.process_string(Index: integer); const delims = [#9]; var I,hpos: integer;     datastring, outstring : ansistring ;     doseoffsets : array of integer;     offset : integer; begin  offset := index;  outstring := '';  datastring := indata[index];  setlength(doseoffsets,dosepositions.Count-1);   hpos := wordposition(3,datastring,delims);   for i := 0 to dosepositions.count -1 do  doseoffsets[i] :=  hpos + ((strtoint(dosepositions[i])) * 6);   outstring := extractword(1,datastring,delims) + #9 + extractword(2,datastring,delims) ;   for i := 0 to dosepositions.count-1 do  begin    outstring := outstring + #9 + copy(datastring,doseoffsets[i],5);  end;  outdata.strings[offset] := outstring;end; ---------------------------------------------------------------------- liewald · 2017-09-26 09:57 willdo ---------------------------------------------------------------------- marcov · 2017-09-26 10:59 Just check if the index is in the correct range before you use it, e.g. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if Not ( (index>=0) and (index