Programming => Packages and Libraries => Topic started by: y.ivanov on May 09, 2021, 06:22:56 pm

Title: [SOLVED] PascalScript SIGFPE
Post by: y.ivanov on May 09, 2021, 06:22:56 pm
I am trying to make a small project using PascalScript included into the Lazarus distribution. I have an issue when I deliberately code a zero division into the script.

My expectations was that the TPSScript.Execute will return false and then ExecErrorCode will be ErDivideByZero, but unfortunately the whole program aborts and the control is not returned to my calling method.

The exception is thrown in TPSExec.DoCalc, upsRuntime.pas, line 5948.

I can see later in the TPSExec.DoCalc some exception handling code, line 6329:

Code: Pascal  [Select][+][-]
  1.   except
  2.     {$IFDEF DELPHI6UP}
  3.     Tmp := AcquireExceptionObject;
  4.     {$ELSE}
  5.     if RaiseList <> nil then
  6.     begin
  7.       Tmp := Exception(PRaiseFrame(RaiseList)^.ExceptObject);
  8.   ...

I have tried to enable all runtime checks in the project, but it doesn't helps.

The message is:

Project PAScr raised exception class 'External: SIGFPE'.

 In file 'uPSRuntime.pas' at line 5948:
btS32: tbts32(var1^) := tbts32(var1^) div tbts32(var2^);

The Pascal script is:
Code: Pascal  [Select][+][-]
  1. var
  2.   A, B, C: Integer;
  3. begin
  4.   A := 1;
  5.   B := 2;
  6.   C := A + B;
  7.   C := B div 0;
  8. end.

Does anybody have an idea what I'm missing?

Lazarus 1.9.0 r63034 FPC 3.1.1 i386-win32-win32/win64
Title: Re: PascalScript SIGFPE
Post by: y.ivanov on May 09, 2021, 10:19:22 pm
Update: Everything runs as expected when started without debugger. It is not related to PascalScript. It seems to be related to the GDB.

Tested with the test example from,22877.msg135755.html#msg135755
Also aborts immediately on SGFPE when debugged (doesn't write the class name) and works fine when started in console.

Most probably the GDB.exe must be updated...
TinyPortal © 2005-2018