oh oh those sigsegv errors lazarus / 55-TAChart ---------------------------------------------------------------------- frederic · 2016-03-22 15:41 dear specialists , i have some strange things  and it has to do with setting the ranges of a chart axis in an application which is too large  to communicate  ;therefore i describe what i see. The sigsegv-error refers to the chartutils unit  procedure UpdateMinMax   line 514. ,stating that the minvalue of the axis is obviously lower than the mininum value This all happens in Y-axis of a pane setup  (3 panes on top of each other) when data to the series are added. to my astonishment it doesn't happen in a consistent way.;once you think you have solved the issue it returnes  after some time again . In this program the panes are setup as in the  thread “proper y-axis with panes” and “chart repaint”. The last one was also referring to oberved instabilities but couldn't be demonstrated at last. Now i observe the following the program has produced the  charts i wanted . I close the  program and start it up again with the same dataset and every thing is oke but at some time , without having made code changes. I get the error. When i then repeat  a new startup, this the error is still there . Then i made the following code change: The data are being add in a for loop  i made a stop  in this loop by introducing a showmessage there Having done this and having run the program appr 10 times it looks …..stable.??? i cannot explain this who hase some suggestions to tackle such a problem?. frederic ---------------------------------------------------------------------- wp · 2016-03-22 22:42 Looks like some missing initialization somewhere. But, please understand, you must provide a compilable demo which shows the issue and instructions how to reproduce it. Otherwise I cannot help because I do not see such a behavior. I know it's difficult sometimes... Since a ShowMessage removes the issue I think there is maybe a pending message hanging around in the message queue. Call Application.ProcessMessages instead, it empties the message queue but does not interrupt your program flow. Maybe it helps. But it would just be a workaround, no fix... ---------------------------------------------------------------------- frederic · 2016-03-23 09:45 wp, i made the replacements to Application.ProcessMessages and that helped. Then i started the further search for "a missing initialization' and made adaptions which were unsuccesfull, so i restored the situation as you suggested and now it didnt help anymore so , i am back with my "showmessage solution" and that is still functioning which will do for the time beiing. ---------------------------------------------------------------------- Eugene Loza · 2016-03-23 11:59 If you get SIGSEGVs randomly it's a good hint that there is a range- check error somewhere. Try adding {$R+}{$Q+} to every unit in the project and see if it raises any errors. Also check the compilation notes for warnings of uninitialized variables. ---------------------------------------------------------------------- frederic · 2016-03-23 13:13 i am not familiar with   {$R+}{$Q+}  . how do i apply this statement and at what location in the unit, as i apply a lot of inherited forms  ,how do i use it there thanks for the reaction ,by the way frederic ---------------------------------------------------------------------- howardpc · 2016-03-23 13:50 These compiler directives can go anywhere in the unit. A logical place is with any other directives. So typically you might see 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 unit myUnit; {$mode objfpc} // or {$mode delphi}{$H+}{$R+}{$Q+} Rather than add such directives on a per-unit basis it is usually better to enable them for the whole Lazarus project. Project->Project Options..., Debugging page. Tick the box marked [ ]  Range (-Cr). ---------------------------------------------------------------------- engkin · 2016-03-23 15:27 I don't think that range checking {$R+} or overflow checking {$Q+} is relevant to the problem mentioned in this thread, as both deal with integer numbers and indexes. The problem happens, according to the OP, in UpdateMinMax: 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 UpdateMinMax(AValue: double; var AMin, AMax: double);  begin    if IsNan(AValue) then      exit;    if AValue < AMin then  //<---- I assume this is line 514 mentioned in the OP      AMin := AValue;    if AValue > AMax then      AMax := AValue;  end; specifically in the highlighted line. This means that either AValue or AMin is not a valid double number? My justification for such an opinion is that IsNan(AValue) does not pass the number to the FPU, while AValue < AMin does. I agree with wp "missing initialization somewhere". AValue or AMin contains some random value. Edit: And since it passed IsNan(AValue) then the problem is in AMin. ---------------------------------------------------------------------- frederic · 2016-03-23 15:57 he engkin, good remark here, indeed, i use integers there instead of double!!! in my case  :Avalue is an  integer; a saw the value in the debugger stop .                    and that value corresponded with the minimumvalue of   the  y-axis in the lowest pane.       the   "amin"  was fed in double; i will check if this solves the issue, i will come back in due course thanks frederic ---------------------------------------------------------------------- engkin · 2016-03-23 16:25 Actually IsNan is not enough to guarantee that AValue holds a valid number. ---------------------------------------------------------------------- frederic · 2016-03-24 10:46 After extensive search the question ,whether integer or double values are used ,is not applicable. all the settings are done directly in values not via an intermediate variables. In the past however i have observed that i lost sometimes(not always)  the settings in the proces, which were initiated via the objectinspector during the pane setup proces. (in the "chart repaint thread "in this forum  this led to demo project  where the set up steps could be changed arbitraly).Conclusion :it is stable; In de program I solved it by listing these steps in a  " panebuilding"procedure,which is updated when the charts go beyond the minmax ranges we will dig further frederic ---------------------------------------------------------------------- frederic · 2016-04-12 09:21 Some feedback about this issue. in my application the chartform is a standard  form which is inherited many times . At first i had made the settings for the pane construction via the object inspector.I made already  the statement this wasn't stable and was loosing the pane settings many times, so i made a procedure "pane building" where i hardcoded the settings again  with the same as done via the object inspector. This panebuilding procedure was used in zooming and panning actions   and when the first data where fed to the chart I changed now that and made this procedure only part of  the formcreate  and it looks stable and was able to remove all showmessage stops ---------------------------------------------------------------------- frederic · 2016-04-19 14:39 it was rather frustrating not to be able to demonstrate  the  the sigsegv errors  above. may be i could now it looks like that i get the same issue in the attached test project which is build in the same way as in my larger application. just press makecharts..... frederic ---------------------------------------------------------------------- wp · 2016-04-19 15:21 First observation: There is no chart in this demo --> your issue definitely is not related to TAChart. Second observation: You use a lot of dynamic arrays, but I am not sure if your don't run over the defined lengths. Lots of strange things can happen in this case. First example (in MakeData) (I reformatted your code for better reading by myself): 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   for n:=0 to  Fmaxfutmin2 -Femptymin do  begin    FSerie21[n]:= 100*cos(0.05*pi*n );    FSerie22[n]:= 4*sin(312.33*pi*n);    FSerie23[n]:= acoff3 * fserie21[n] + Bcof3 * fserie22[n];    if fserie23[n] < lowest2 then lowest2 := FSserie23[n];    if fserie23[n] > highest2 then highest2 := FSerie23[n];     if n >= Fmaxfutmin2 - Femptymin - Fhistmin1 then    begin      FSerie11[m] := fserie21[n];    FSerie12[m] := fserie22[n];      FSerie13[m] := fserie23[n];      if FSerie13[m] < lowest1 then lowest1 := fserie13[m];      if FSerie13[m] > highest1 then highest1 := fserie13[m];      if n < FMaxFutMin2-FEmptyMin then inc(m);  // <--- Here, m can exceed the Length defined for FSerie11 etc.    end;  end; Second example 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.MakeXaxis(anumberofdays,chartnr,maxmin:integer);var  intdatestart,n,m,zz: integer;begin  SetLength(FTimeArr[chartnr], MaxMin+2);          // This defines that m must be < MaxMin+2  SetLength(FIntDayArr[chartnr], ANumberOfDays+2);  SetLength(FOneMinuteNDofIncrPosition[chartnr],maxmin+2);   intDateStart := Trunc(now) - ANumberOfDays;  m := 0;  for n:=0 to anumberofdays do  begin       Fintdayarr[chartnr,n]:=intdatestart + n;       for zz:=Fopenmin to Fclosemin do       begin            inc(m);   // Here m can grow without respecting the allowed length set in the first line!            Ftimearr[chartnr,m]:= Fintdayarr[chartnr,n]+ zz/1440;            Foneminutendofincrposition[chartnr,m]:=m;       end;  end;end; Third example - maybe no problem but my feeling tells me... 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.start_making_chartsbtnClick(Sender: TObject);begin  ...  MakeXAxis(Fchart1nod,1,Fmaxfutmin1);// prepare array for the x-axislabels  // the "1" is the parameter "chartnr" which is used as the first index of the 2d array FTimeArr and FIntDayArr.  // Both are dimensioned by "SetLength(.. , 3)", i.e. begin with index 0.  // Why do you use index 1 to start with? There is probably also index 3 somehwhere.  // This is out of the allowed range!end; ---------------------------------------------------------------------- frederic · 2016-04-19 19:14 QuoteFirst observation: There is no chart in this demo --> your issue definitely is not related to TAChart. the chart is on the form of the masterchartunit , that form, is inherited in via following units 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 implementationuses chartONEunit1,chartTWOunit1;var  ourgraphone:Tmastergraffrm1;  ourgraphtwo:Tmastergraffrm2;  was the download not complete? with the error an assembler screen is shown and when you want the details it refers  to customform.inc line 3067: 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 constructor TForm.Create(TheOwner: TComponent);begin  FLCLVersion:=lcl_version;  inherited Create(TheOwner);end; QuoteSecond observation: You use a lot of dynamic arrays, but I am not sure if your don't run over the defined lengths. Lots of strange things can happen in this case. when you run the program without line 104 and line 105 in the startunit so avoid 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 ourgraphone :=Tmastergraffrm1.create(application);//<<---------------------------- ----her was the----ERRORourgraphone.show; then everything works fine meaning that the the dynamic arraylengths are not the problem. btw : i do start with 1 instead 0 in dynamic arrays  because that saves me a lot of typing n-1 in my mathematical formula and has proven to avoid mathematical errors(of course we shouldn't end up pascal errors) ---------------------------------------------------------------------- frederic · 2016-04-19 19:24 QuoteMakeXAxis(Fchart1nod,1,Fmaxfutmin1);// prepare array for the x-axislabels   // the "1" is the parameter "chartnr" which is used as the first index of the 2d array FTimeArr and FIntDayArr.   // Both are dimensioned by "SetLength(.. , 3)", i.e. begin with index 0.   // Why do you use index 1 to start with? There is probably also index 3 somehwhere.   // This is out of the allowed range! yes ,you are rigth,but there is no number 3 .in this example i want to approach only 1 chart , but i was already preparing for more  ; the setlengths will have be  to changed then. experience is the result of condensed misery ---------------------------------------------------------------------- wp · 2016-04-19 19:25 Quote from: frederic on April 19, 2016, 09:14:56 pmQuoteFirst observation: There is no chart in this demo --> your issue definitely is not related to TAChart. Sorry I was caught by the dynamic array and did not open the other forms - my fault. Quote from: frederic on April 19, 2016, 09:14:56 pmbtw : i do start with 1 instead 0 in dynamic arrays  because that saves me a lot of typing n-1 in my mathematical formula and has proven to avoid mathematical errors(of course we shouldn't end up pascal errors) This is wrong because FPC internally always begins indexing with 0. At the moment when you access the last array element which you access the index n you run out of the defined index range. Example 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 var  x: array of Integer;begin  SetLength(x, 3);  // --> this defines an array with three elements.  //      For FPC, they have index 0, 1, and 2: x[0], x[1], x[2]  // In your way of couning the first index is 1, the last index is 3  // You can access index 1 and 2, but you cannot access index 3!!! ---------------------------------------------------------------------- frederic · 2016-04-19 19:38 QuoteThis is wrong because FPC internally always begins indexing with 0. At the moment when you access the last array element which you access the index n you run out of the defined index range. i agree, therefore . all my setlengths are standard 1 point higher ---------------------------------------------------------------------- wp · 2016-04-19 20:05 I tried to trace into "ourgraphone:=Tmastergraffrm1.create(application);", but the code crashes already at the very first line of TForm.Create, long before any TAChart code is reached.  Before I investigate into this issue any further you must convince me that the dynamic array indexes do not run out of the defined dimensions. As long as they do, anything can happen... Please replace MakeXAxis of your demo with this code, and see what happens: 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.MakeXaxis(anumberofdays,chartnr,maxmin:integer);var  intdatestart,n,m,zz: integer;begin  SetLength(FTimeArr[chartnr], MaxMin+2);  SetLength(FIntDayArr[chartnr], ANumberOfDays+2);  SetLength(FOneMinuteNDofIncrPosition[chartnr],maxmin+2);   intDateStart := Trunc(now) - ANumberOfDays;  m := 0;  for n:=0 to anumberofdays do  begin       Fintdayarr[chartnr,n]:=intdatestart + n;       for zz:=Fopenmin to Fclosemin do       begin            inc(m);            if m >= Length(FTimearr) then              raise Exception.Create('m runs beyond of the allowed array dimensions');          Ftimearr[chartnr,m]:= Fintdayarr[chartnr,n]+ zz/1440;          Foneminutendofincrposition[chartnr,m]:=m;       end;  end;end; Quote from: frederic on April 19, 2016, 09:38:05 pmall my setlengths are standard 1 point higher I don't believe you... The fractions of a second for typing "-1" add up to much less time you must spend for debugging the mess caused by unconventional array access. ---------------------------------------------------------------------- frederic · 2016-05-02 19:32 wp,i am sorry for the delayed answer(I had an accident, from which i now try to recover). Indeed in the example,  above, the reason for the sigsegv  there lies in the wrong setlenght of the arrays  ,and that is not what i was aiming to demonstrate i wil come back when i am in a better mood frederic ---------------------------------------------------------------------- wp · 2016-05-02 20:02 Quote from: frederic on May 02, 2016, 09:32:40 pmI had an accident, from which i now try to recoverOh my god! I hope nobody was hurt seriously and that you'll recover soon.