Recent

Author Topic: FPC 3.3.1 Error 216 General Protection fault for abs with GO32V2 / SSE2  (Read 449 times)

Gammatester

  • Jr. Member
  • **
  • Posts: 69
There is a problem with the abs function for FPC3.3.1/GO32V2 when using SSE2. FPC was installed from go32v2-fpc-3.3.1.x86_64-linux.tar.gz. The following program
Code: Pascal  [Select]
  1. program t_abssse;
  2. var
  3.   x: double;
  4. begin
  5.   writeln('Abs bug with SSE/GO32V2');
  6.   x := -1;
  7.   writeln('x=',x);
  8.   writeln('sin(x)=',sin(x));
  9.   writeln('abs(x)=',abs(x));
  10. end.
  11.  
works as expected under Window XP and Windows 8 without SSE and throws a runtime error 216 when compiled with  -CfSSE2.  Should this be reported as an issue in the bugtracker?
Code: [Select]
Windows XP

D:\FPC331D\bin\go32v2>fpc
Free Pascal Compiler version 3.3.1-r20:40421 [2018/11/30] for i386
Copyright (c) 1993-2018 by Florian Klaempfl and others

D:\FPC331D\bin\go32v2>ver
Microsoft Windows XP [Version 5.1.2600]

D:\FPC331D\bin\go32v2>fpc.exe t_abssse.pas

D:\FPC331D\bin\go32v2>t_abssse.exe
Abs bug with SSE/GO32V2
x=-1.0000000000000000E+000
sin(x)=-8.41470984807896506665E-0001
abs(x)= 1.0000000000000000E+000

D:\FPC331D\bin\go32v2>fpc -CfSSE2 t_abssse.pas

D:\FPC331D\bin\go32v2>t_abssse.exe
Abs bug with SSE/GO32V2
x=-1.0000000000000000E+000
sin(x)=-8.41470984807896506665E-0001
Runtime error 216 at $000018B2
  $000018B2
  $00001795

abs(x)=
D:\FPC331D\bin\go32v2>

Windows 8

C:\FPC331D\bin\go32v2>fpc.exe
Free Pascal Compiler version 3.3.1-r20:40421 [2018/11/30] for i386
Copyright (c) 1993-2018 by Florian Klaempfl and others

C:\FPC331D\bin\go32v2>ver
Microsoft Windows [Version 6.2.8400]

C:\FPC331D\bin\go32v2>fpc t_abssse.pas

C:\FPC331D\bin\go32v2>t_abssse.exe
Abs bug with SSE/GO32V2
x=-1.0000000000000000E+000
sin(x)=-8.41470984807896506665E-0001
abs(x)= 1.0000000000000000E+000

C:\FPC331D\bin\go32v2>fpc -CfSSE2 t_abssse.pas

C:\FPC331D\bin\go32v2>t_abssse.exe
Abs bug with SSE/GO32V2
x=-1.0000000000000000E+000
sin(x)=-8.41470984807896506665E-0001
Runtime error 216 at $000018B2
  $000018B2
  $00001795

abs(x)=
C:\FPC331D\bin\go32v2>

lucamar

  • Sr. Member
  • ****
  • Posts: 463
Re: FPC 3.3.1 Error 216 General Protection fault for abs with GO32V2 / SSE2
« Reply #1 on: December 01, 2018, 09:32:42 pm »
Have you tried in an actual DOS box? It may be a strange interaction between the extender and the OS treatment of the FPU.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 1.8.4/FPC 3.0.4 on:
(K)Ubuntu 11..16, Windows XP SP3 (Home/Prof.) and various DOS incarnations.

Gammatester

  • Jr. Member
  • **
  • Posts: 69
Re: FPC 3.3.1 Error 216 General Protection fault for abs with GO32V2 / SSE2
« Reply #2 on: December 01, 2018, 10:06:54 pm »
Have you tried in an actual DOS box? It may be a strange interaction between the extender and the OS treatment of the FPU.
This makes no difference, here the results for Windows 98 and DOSBox (the first runs are without SSE the second with SSE):
Code: [Select]
C:\TMP>ver
Windows 98 [Version 4.10.1998]

C:\TMP>t_abs.exe
Abs bug with SSE/GO32V2
x=-1.0000000000000000E+000
sin(x)=-8.41470984807896506665E-0001
abs(x)= 1.0000000000000000E+000

C:\TMP>T_ABSSSE.EXE
Abs bug with SSE/GO32V2
x=-1.0000000000000000E+000
sin(x)=-8.41470984807896506665E-0001
Runtime error 216 at $000018B2
  $000018B2
  $00001795

abs(x)=
C:\TMP>

DOSBox version 0.74-2. Reported DOS version 5.00.
Abs bug with SSE/GO32V2
x=-1.0000000000000000E+000
sin(x)=-8.41470984807896506665E-0001
abs(x)= 1.0000000000000000E+000

Abs bug with SSE/GO32V2
x=-1.0000000000000000E+000
sin(x)=-8.41470984807896506665E-0001
abs(x)=
Error and error addr only displayed on screen, could not be redirected with DOSBox
« Last Edit: December 01, 2018, 10:12:16 pm by Gammatester »

lucamar

  • Sr. Member
  • ****
  • Posts: 463
Re: FPC 3.3.1 Error 216 General Protection fault for abs with GO32V2 / SSE2
« Reply #3 on: December 01, 2018, 10:58:54 pm »
Sorry, by "DOS box" I meant a computer with a real DOS (as in MS-DOS, DR-DOS, FreeDOS, ...) in it, not the emulator :D But Windows 98 (boot-up with no GUI, I hope?) is enough test.

I kinfd of remember there was some problem with the FPU control word but I haven't been able to find the reference, sorry again. :-[
« Last Edit: December 01, 2018, 11:03:25 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 1.8.4/FPC 3.0.4 on:
(K)Ubuntu 11..16, Windows XP SP3 (Home/Prof.) and various DOS incarnations.

Gammatester

  • Jr. Member
  • **
  • Posts: 69
Re: FPC 3.3.1 Error 216 General Protection fault for abs with GO32V2 / SSE2
« Reply #4 on: December 01, 2018, 11:22:27 pm »
Sorry, by "DOS box" I meant a computer with a real DOS (as in MS-DOS, DR-DOS, FreeDOS, ...) in it, not the emulator :D But Windows 98 (boot-up with no GUI, I hope?) is enough test.
Again no difference, same output for Win98 GUI / NoGUI, and the results for
Code: [Select]
MS-DOS Version 6.22

Abs bug with SSE/GO32V2
x=-1.0000000000000000E+000
sin(x)=-8.41470984807896506665E-0001
abs(x)= 1.0000000000000000E+000

Abs bug with SSE/GO32V2
x=-1.0000000000000000E+000
sin(x)=-8.41470984807896506665E-0001
abs(x)=
DOS version run from floppy on real hardware (Pentium 4).