* * *

Author Topic: Exception SIGFPE when debugger run full speed.  (Read 2623 times)

Ruptor

  • Jr. Member
  • **
  • Posts: 94
Exception SIGFPE when debugger run full speed.
« on: February 11, 2013, 02:26:05 am »
My code scrolls the axis continuously because I do ADDXY in a loop and it gives an exception error "extern SIGFPE" in tachartaxis at line 1143 when run without a break point. By adding a break point and then just continuing on with the code the error doesn't happen. It seems like a timing thing where the system can't keep up with drawing the continuously changing axis values as more points are added.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Exception SIGFPE when debugger run full speed.
« Reply #1 on: February 11, 2013, 02:49:58 am »
Please post a small  application demonstrating your problem

Ruptor

  • Jr. Member
  • **
  • Posts: 94
Re: Exception SIGFPE when debugger run full speed.
« Reply #2 on: February 11, 2013, 01:22:40 pm »
For you experts making a small project is easy but for me it is a big task. Anyway I tried but found another bug or maybe the same bug giving a different result. I tried to mimic the time taken in my code by using a sleep(10) but the code doesn't work when it is used. No exception is generated but the form never appears.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Exception SIGFPE when debugger run full speed.
« Reply #3 on: February 11, 2013, 03:32:54 pm »
The project you posted works for me both with and without call to Sleep.
(Of course, with Sleep it takes about 2 minutes to run -- but it is as programmed).

So this example is probably not enough to reproduce your problem.

Try to debug -- what is in stacktrace?
What are values of FMax^ and FMin^ ?

Ruptor

  • Jr. Member
  • **
  • Posts: 94
Re: Exception SIGFPE when debugger run full speed.
« Reply #4 on: February 12, 2013, 01:11:20 am »
yes it was not the right code to show the problem. I think I am doing something wrong with parameters in a procedure because while investigating I noticed that returned parameters were not being set. Maybe this problem as attached is inducing the error but it still looks like a race situation to me. Shall I post this parameter problem under general code instead? This example sets values in a procedure but the values don't come back according to the debugger but if I remove the string array from the procedure parameters the values do get returned. I am probably misunderstanding something about the string array.  :-\

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Exception SIGFPE when debugger run full speed.
« Reply #5 on: February 12, 2013, 01:43:06 am »
It seems that you are not familiar with the difference between value and variable parameters.
Please read documentation.

In general, I advise you to either read a book or take a course in Pascal.


Ruptor

  • Jr. Member
  • **
  • Posts: 94
Re: Exception SIGFPE when debugger run full speed.
« Reply #6 on: February 12, 2013, 02:04:55 am »
Whether the variables have a returned value or not is irrelevant to the original SIGFPE problem since the graph is just a straight line. A break point shouldn't be necessary to make the code run correctly. The variables work fine by reference until I put the string array infront and I shall endeavour to understand why the open array screws things up especially since it isn't even accessed.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Exception SIGFPE when debugger run full speed.
« Reply #7 on: February 12, 2013, 02:13:43 am »
Quote
Whether the variables have a returned value or not is irrelevant to the original SIGFPE problem
I am not so sure. Please read documentation.

It is quite possible that the problem with your code is actually that point coordinates are not initialized,
so garbage is passed to AddXY procedure. This could also explain random nature of the bug.

Ruptor

  • Jr. Member
  • **
  • Posts: 94
Re: Exception SIGFPE when debugger run full speed.
« Reply #8 on: February 12, 2013, 02:27:33 am »
My program never loads the form when I enable the sleep command which is also different to what you found so more than one thing is screwed up. I will try and demonstrate the SIGFPE error in code.

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Exception SIGFPE when debugger run full speed.
« Reply #9 on: February 12, 2013, 05:35:03 am »
Quote
My program never loads the form when I enable the sleep command
How long did you wait? You need at least 2 minutes, perhaps as long as 5 minutes.

Ruptor

  • Jr. Member
  • **
  • Posts: 94
Re: Exception SIGFPE when debugger run full speed.
« Reply #10 on: February 12, 2013, 07:15:36 pm »
I changed the sleep to 1mS instead of 10mS but it didn't bring the form up after more than 10 minutes. On another computer with 1mS set it takes 2.75 minutes so it is computer dependant and I will check the non working computer tonight when I go home because it might be a different version of software.
since I call "Application.ProcessMessages" in the loop shouldn't the progress bar and the graph appear at some point over the 2 minute period?

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: Exception SIGFPE when debugger run full speed.
« Reply #11 on: February 12, 2013, 10:23:54 pm »
Quote
shouldn't the progress bar and the graph appear at some point
No, since your code is inside FormShow event so it is executed before the form is visible.

Ruptor

  • Jr. Member
  • **
  • Posts: 94
Re: Exception SIGFPE when debugger run full speed.
« Reply #12 on: February 13, 2013, 12:26:49 am »
I upgraded the computer that does not run the code from r40186 to r40275 and it finishes now but takes longer. This rings alarm bells for me on top of the fact that the time period for the code to finish is exceedingly long. The code takes 5 seconds to complete without a sleep command so the code takes practically no time to go around the plotting loop of 10000 points. How come adding 1mS sleep period to each loop takes 3 minutes when it should only add 10 seconds. It looks like the sleep command can't actually give 1mS due to overheads and it ends up being more than 10mS.

Ruptor

  • Jr. Member
  • **
  • Posts: 94
Re: Exception SIGFPE when debugger run full speed.
« Reply #13 on: February 17, 2013, 12:26:53 am »
I have done some more code and the SIGFPE error is back. Here is the log of the problem where I just opened Lazarus and did one run to the error then shut it down. The offending lines in my code are;
Code: [Select]
  COGctl:= num[Period] * denom[Period];or
Code: [Select]
  COGctl:= num[Period] / denom[Period];
but this works
Code: [Select]
COGctl:= num[Period] + denom[Period];Also by setting the values of num and denom to 2 & 3 respectively it makes the divide and multiply versions work. So it looks like it does not like dealing with small values in multiplying. I know one has to check for divide by zero but one doesn't normally worry about multiplying small amounts.

Ruptor

  • Jr. Member
  • **
  • Posts: 94
Re: Exception SIGFPE when debugger run full speed.
« Reply #14 on: February 17, 2013, 02:53:14 pm »
After more testing I found that code position was the key so figured maybe something to do with the stack inside the routine since I am using dynamic arrays. I found that by reducing the size of my four fixed arrays to this it worked.
Code: [Select]
  opp[0..9999] of real;
  hip: array[0..9999] of real;
  lop: array[0..9999] of real;
  clp: array[0..9999] of real;
Then I tried to see what size of array it would let me pass to my function. These values worked but 12210 on the two arrays didn't.
Code: [Select]
  opp[0..9999] of real;
  hip: array[0..12209] of real;
  lop: array[0..12209] of real;
  clp: array[0..9999] of real;
The problem was still not straight forward because I changed the declaration to this and it didn't work anymore.
Code: [Select]
opp,hip,lop,clp: array[0..9999] of real;At no time is a compile error given saying I can't have large arrays.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads