Recent

Author Topic: oh oh those sigsegv errors  (Read 10286 times)

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: oh oh those sigsegv errors
« Reply #15 on: April 19, 2016, 09:25:14 pm »
Quote
First 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.

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)
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][+][-]
  1. var
  2.   x: array of Integer;
  3. begin
  4.   SetLength(x, 3);
  5.   // --> this defines an array with three elements.
  6.   //      For FPC, they have index 0, 1, and 2: x[0], x[1], x[2]
  7.   // In your way of couning the first index is 1, the last index is 3
  8.   // You can access index 1 and 2, but you cannot access index 3!!!

frederic

  • Full Member
  • ***
  • Posts: 226
Re: oh oh those sigsegv errors
« Reply #16 on: April 19, 2016, 09:38:05 pm »
Quote
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.

i agree, therefore . all my setlengths are standard 1 point higher

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: oh oh those sigsegv errors
« Reply #17 on: April 19, 2016, 10:05:55 pm »
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][+][-]
  1. procedure TForm1.MakeXaxis(anumberofdays,chartnr,maxmin:integer);
  2. var
  3.   intdatestart,n,m,zz: integer;
  4. begin
  5.   SetLength(FTimeArr[chartnr], MaxMin+2);
  6.   SetLength(FIntDayArr[chartnr], ANumberOfDays+2);
  7.   SetLength(FOneMinuteNDofIncrPosition[chartnr],maxmin+2);
  8.  
  9.   intDateStart := Trunc(now) - ANumberOfDays;
  10.   m := 0;
  11.   for n:=0 to anumberofdays do
  12.   begin
  13.        Fintdayarr[chartnr,n]:=intdatestart + n;
  14.        for zz:=Fopenmin to Fclosemin do
  15.        begin
  16.             inc(m);
  17.             if m >= Length(FTimearr) then
  18.               raise Exception.Create('m runs beyond of the allowed array dimensions');
  19.             Ftimearr[chartnr,m]:= Fintdayarr[chartnr,n]+ zz/1440;
  20.             Foneminutendofincrposition[chartnr,m]:=m;
  21.        end;
  22.   end;
  23. end;

all 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

  • Full Member
  • ***
  • Posts: 226
Re: oh oh those sigsegv errors
« Reply #18 on: May 02, 2016, 09:32:40 pm »
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

  • Hero Member
  • *****
  • Posts: 11830
Re: oh oh those sigsegv errors
« Reply #19 on: May 02, 2016, 10:02:58 pm »
I had an accident, from which i now try to recover
Oh my god! I hope nobody was hurt seriously and that you'll recover soon.

 

TinyPortal © 2005-2018