Recent

Author Topic: SIGFPE in function TAxisCoeffHelper.CalcOffset...  (Read 4233 times)

CM630

  • Hero Member
  • *****
  • Posts: 1091
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
SIGFPE in function TAxisCoeffHelper.CalcOffset...
« on: April 20, 2013, 02:14:28 pm »
I get SIGFPE in
Code: [Select]
function TAxisCoeffHelper.CalcOffset(AScale: Double): Double;
begin
    Result := (FLo + FHi) / 2 - AScale * (FMin^ + FMax^) / 2;
end;   
when FMin^= +inf and FMax^= +inf.

Could there be a bug somewhere, I suppose FMin^ and FMax^ should not be able to receive such values.
Unfortunately I cannot send a reasonably small part of code, to reproduce the issue, generally it happens when  the chart is resized.
« Last Edit: April 20, 2013, 02:19:43 pm by paskal »
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: SIGFPE in function TAxisCoeffHelper.CalcOffset...
« Reply #1 on: April 20, 2013, 06:24:38 pm »
It's hard to tell what you do wrong if there are no more details: which series? using UserdefinedChartSource? Do you change axis scaling (I remember a thread on this topic by yourself)?

CM630

  • Hero Member
  • *****
  • Posts: 1091
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: SIGFPE in function TAxisCoeffHelper.CalcOffset...
« Reply #2 on: April 22, 2013, 09:34:07 am »
So:
1. About axis scaling- a change the maximum and minimum of the axises (left and bottom). I do not use scaling of the series.
2. I do not understand what you mean by „which series". I use several lineseries in a same chart, although exactly one of them contains more than one point.
3. I have no idea what „UserdefinedChartSource" is (so far I only guess by the name), so I suppose that I do not use it. As I wrote, I use line series and I add them using chart.series.addXY.

4. I have some clue
General: In my case several charts are drawn (element of an array). Charts are created dynamically.  All these charts are in a tab sheet. The tab sheet is resized vertically, so all the charts can fit in it. There is a vertical scrollbar on the main window, so I can scroll to see all the charts.

4,1. Case 1:
The window of the application is not maximized. The summary height of the charts if greater than the height of the screen. Charts are drawn okay. When the window of the application is maximized or when the scrollbar of the application window is moved SIGFPE occurs.

4,2. Case 2.
The window of the application is maximized. The summary height of the charts if greater than the height of the screen. Charts are drawn okay. No SIGFPE occurs, when minimizing, restoring or maximizing the application window size again. SIGFPE occurs when the scrollbar of the main window is moved. Yet, this does not happen always, but depends on the height of the waveforms. If they have greater heights, SIGFPE occurs, on smaller height (even if their summary height than the height of the screen) SIGFPE does not occur.

4,3. Case 3
The summary height of the charts if smaller than the height of the screen. Charts are drawn okay. No SIGFPE occurs, when minimizing, restoring or maximizing the application window size again or when moving the scrollbar of the application window.

Under these circumstances I would rather think that there is some bug in TAChart.
If thise info is not enough, I could try to reproduce in some simple app?
« Last Edit: April 22, 2013, 09:40:42 am by paskal »
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: SIGFPE in function TAxisCoeffHelper.CalcOffset...
« Reply #3 on: April 22, 2013, 09:46:25 am »
Quote
If thise info is not enough, I could try to reproduce in some simple app?
Please do so.

CM630

  • Hero Member
  • *****
  • Posts: 1091
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: SIGFPE in function TAxisCoeffHelper.CalcOffset...
« Reply #4 on: April 22, 2013, 12:16:21 pm »
I did try... alas I failed. The sample that I created does not crash. Probably sending you or someone else the entire code won't help. I'll keep on trying...

Yet, there is an addition to Case 1:  Besides maximizing and scrolling, SIGFPE occurs- when the window of the application is moved (dragged) so that its top becomes negative.


Edit: I fixed things, by adding some lines to the following sub:
constructor TAxisCoeffHelper.Init( AAxis: TChartAxis; AImageLo, AImageHi, AMarginLo, AMarginHi: Integer; AMin, AMax: PDouble);

Now it is:

Code: [Select]
constructor TAxisCoeffHelper.Init(
  AAxis: TChartAxis; AImageLo, AImageHi, AMarginLo, AMarginHi: Integer; AMin, AMax: PDouble);
begin
  FAxis := AAxis;
  FImageLo := AImageLo;
  FImageHi := AImageHi;
  FMin := AMin;
  FMax := AMax;
  FLo := FImageLo + AMarginLo;
  FHi := FImageHi + AMarginHi;

//Newly added lines start here
  if (FMin^= Infinity) and (fMax^= -Infinity) then
      begin
        FMin^:=0;
        FMax^:=0;
      end;
end; 

If someone has a better idea, please let me know. Maybe (FMin^= Infinity) and (fMax^= -Infinity) should be (FMin^= Infinity) or (fMax^= -Infinity)
« Last Edit: April 22, 2013, 01:08:36 pm by paskal »
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: SIGFPE in function TAxisCoeffHelper.CalcOffset...
« Reply #5 on: April 23, 2013, 09:15:42 am »
You should not modify the sources of TAChart because you'll have to redo the modification with every update of Lazarus.

My feeling is that the issue is prepared somewhere in your own code. If it were a general issue with TAChart based on the observations that you made it would be easier for you the reproduce the problem in a simple project. The fact that FMin and FMax are Infinity tells that something is wrong with your axis labelling. You negated my previous question on axis scaling, but you say that you change axis limits - that's what I was thinking of. Temporarily remove this code and look if the problem goes away.

In a somehow similar case of mine it helped to call Chart.Prepare after loading the data into the series.

CM630

  • Hero Member
  • *****
  • Posts: 1091
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: SIGFPE in function TAxisCoeffHelper.CalcOffset...
« Reply #6 on: April 23, 2013, 02:28:31 pm »
You should not modify the sources of TAChart because you'll have to redo the modification with every update of Lazarus.
I am fully aware of that, but for the time being this solution would be less time consuming. I am quite sure that an edit like mine is necessary, but also I'm quite sure that I am not using at the right place.

My feeling is that the issue is prepared somewhere in your own code.
That could be the case, but on the other hand TAChart runs into a case which it does not how to handle (incl. it does not issue a reasonable error message).

If it were a general issue with TAChart based on the observations that you made it would be easier for you the reproduce the problem in a simple project. The fact that FMin and FMax are Infinity tells that something is wrong with your axis labelling.
 You negated my previous question on axis scaling, but you say that you change axis limits - that's what I was thinking of. Temporarily remove this code and look if the problem goes away.
I was not sure what you meant by axis scaling. I use chart.extents:=, and I set logicalextents, too.
I really did a simple project, but it does not cause SIGFPE.
Once I managed to cause a SIGFPE when changing the vertical extents, but I could not do it again.
One thing that I am sure is that I do not use any events, related with moving the application window, but SIGFPE is generated in this cases. Maybe the problem is not in TAchart itself, but in Lazarus.

In a somehow similar case of mine it helped to call Chart.Prepare after loading the data into the series.
I'll try chart.prepare. Sometimes I do not work on the app for weeks, so it does not stay fresh in my memory, but AFAIR I put a delay (wait) somewhere in the app, because TAchart used to crash without it, maybe Chart.Prepare could be the right solution.
« Last Edit: April 23, 2013, 02:35:29 pm by paskal »
Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

 

TinyPortal © 2005-2018