View Issue Details

IDProjectCategoryView StatusLast Update
0036900FPCRTLpublic2020-04-12 08:53
Reporternanobit Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status newResolutionopen 
Platformwin32OSWindows 
Product Version3.3.1 
Summary0036900: TranslateMxcsr() incomplete
Descriptionsyswin.inc: TranslateMxcsr() can select the wrong exception type (masked in collection).

The concept should be: Only unmasked exceptions trigger the exception handler;
subsequently TranslateMxcsr() is called to find an unmasked exception (likely the same),
but mxcsr can contain unmasked and masked exceptions together (accumulated).
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

nanobit

2020-04-12 08:53

reporter   ~0122089

Solution: I refined the existing conditionals to respect the mask (part of mxcsr):

const
  MXCSR_IE = $01;
  MXCSR_DE = $02;
  MXCSR_ZE = $04;
  MXCSR_OE = $08;
  MXCSR_UE = $10;
  MXCSR_PE = $20;

// see also i386.inc: MM_Mask...
  MXCSR_IM = $0080;
  MXCSR_DM = $0100;
  MXCSR_ZM = $0200;
  MXCSR_OM = $0400;
  MXCSR_UM = $0800;
  MXCSR_PM = $1000;

procedure TranslateMxcsr(mxcsr: longword; var code: longint);
begin
  { we can return only one value, further one's are lost }
  { InvalidOp }
  if (mxcsr and (MXCSR_IM or MXCSR_IE)) = MXCSR_IE then
    code:=-207
  { Denormal }
  else if (mxcsr and (MXCSR_DM or MXCSR_DE)) = MXCSR_DE then
    code:=-206
  { !!reZeroDivide }
  else if (mxcsr and (MXCSR_ZM or MXCSR_ZE)) = MXCSR_ZE then
    code:=-208
  { reOverflow }
  else if (mxcsr and (MXCSR_OM or MXCSR_OE)) = MXCSR_OE then
    code:=-205
  { Underflow }
  else if (mxcsr and (MXCSR_UM or MXCSR_UE)) = MXCSR_UE then
    code:=-206
  { Precision }
  else if (mxcsr and (MXCSR_PM or MXCSR_PE)) = MXCSR_PE then
    code:=-207
  else { this should not happen }
    code:=-255
end;

Issue History

Date Modified Username Field Change
2020-04-12 08:52 nanobit New Issue
2020-04-12 08:53 nanobit Note Added: 0122089