Floating point exception not always caught on Linux i386.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Floating point exception not always caught on Linux i386.

Bernd Mueller-3
Hello,

FPC 3.0.4, Linux i386

the following program should catch the floating point exception
(always), but crashes on the fourth call to the procedure Run:

program test;
{$mode objfpc}{$H+}

procedure Run;
var
    r: Real;
    i: Integer;
begin
    i:= 1;
    try
       r:= i / 0.0;
    except
       r:= 0; // Crash  here on fourth call.
    end;
    Writeln('ok');
end;

begin
    Run;
    Run;
    Run;
    Run;
end.

The output:
ok
ok
ok
Runtime error 207 at $080480F9
   $080480F9
   $0804815C
   $0806644D

The program was compiled with no additional compiler parameters.
I could not reproduce this problem with the trunk version of the
compiler, but all versions down to 2.2.2 show the described behavior.
FPC 2.2.0 is working correct. The 64-bit version of FPC 3.0.4 works
correct too.

Is this something for the bug tracker?

Regards, Bernd.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Floating point exception not always caught on Linux i386.

Bart-48
On Fri, Oct 11, 2019 at 10:39 AM Bernd Mueller <[hidden email]> wrote:

> FPC 3.0.4, Linux i386
>
> the following program should catch the floating point exception
> (always), but crashes on the fourth call to the procedure Run:

See https://www.freepascal.org/docs-html/current/prog/progsu69.html#x76-750001.2.69

--
Bart
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Floating point exception not always caught on Linux i386.

Free Pascal - General mailing list
In reply to this post by Bernd Mueller-3
I use FPC 3.0.4 on Ubuntu 16.04

I get same behavior after compile it with ppc386. 64bit binary executable run OK

Zamrony P. Juhara

Fano Framework, Free Pascal web application framework https://fanoframework.github.io

On Friday, October 11, 2019, 4:39:38 PM GMT+8, Bernd Mueller <[hidden email]> wrote:


Hello,

FPC 3.0.4, Linux i386

the following program should catch the floating point exception
(always), but crashes on the fourth call to the procedure Run:

program test;
{$mode objfpc}{$H+}

procedure Run;
var
    r: Real;
    i: Integer;
begin
    i:= 1;
    try
      r:= i / 0.0;
    except
      r:= 0; // Crash  here on fourth call.
    end;
    Writeln('ok');
end;

begin
    Run;
    Run;
    Run;
    Run;
end.

The output:
ok
ok
ok
Runtime error 207 at $080480F9
  $080480F9
  $0804815C
  $0806644D

The program was compiled with no additional compiler parameters.
I could not reproduce this problem with the trunk version of the
compiler, but all versions down to 2.2.2 show the described behavior.
FPC 2.2.0 is working correct. The 64-bit version of FPC 3.0.4 works
correct too.

Is this something for the bug tracker?

Regards, Bernd.
_______________________________________________
fpc-pascal maillist  -  [hidden email]

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Floating point exception not always caught on Linux i386.

Bernd Mueller-3
In reply to this post by Bart-48
On 10/11/19 10:51 AM, Bart wrote:
>
> See https://www.freepascal.org/docs-html/current/prog/progsu69.html#x76-750001.2.69
>
sorry, I forgot to mention, that I checked with {$SAFEFPUEXCEPTIONS ON},
but it did not change the behavior.

Regards, Bernd.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal