Home My Page Projects Code Snippets Project Openings SML/NJ Bugs
Summary Activity Tracker Lists

[#260] Perform divide on Position.int crashes with FPE on Linux

Date:
2020-07-01 15:56
Priority:
3
State:
Closed
Submitted by:
takayuki goto (eldesh)
Assigned to:
John Reppy (jhr)
Machine Architecture:
x86
Operating System:
Linux
Component:
Compiler
Resolution:
Fixed
Severity:
Major
OS Version:
SML/NJ Version:
110.97
Keywords:
floating point exception
URL:
Transcript (of reproduction):
Source (for reproduction):
```repro.sml val _ = (Position.fromLarge ~0x8000000000000000) div (Position.fromLarge ~1) ``` ```console $ sml -64 repro.sml Standard ML of New Jersey (64-bit) v110.97 [built: Tue May 12 00:16:59 2020] [opening basis/test/repro.sml] [autoloading] [library $SMLNJ-BASIS/basis.cm is stable] [library $SMLNJ-BASIS/(basis.cm):basis-common.cm is stable] [autoloading done] Floating point exception ```
Summary:
Perform divide on Position.int crashes with FPE on Linux

Detailed description
T/O

Comments:

Message  ↓
Date: 2020-07-20 13:33
Sender: takayuki goto

On SML/NJ 100.98 (32bit), similar bug remains yet. :(

```sml
$ bin/sml -32
Standard ML of New Jersey (32-bit) v110.98 [built: Mon Jul 20 11:07:54 2020]
- (Position.fromLarge ~0x8000000000000000) div (Position.fromLarge ~1);
[autoloading]
[library $SMLNJ-BASIS/basis.cm is stable]
[library $SMLNJ-BASIS/(basis.cm):basis-common.cm is stable]
[autoloading done]
val it = ~9223372036854775808 : ?.int64
-
```

Date: 2020-07-01 19:45
Sender: John Reppy

The fact that there is a FPE occurring is not a bug; dividing the most-negative number by ~1 will cause Overflow, which is detected as a SIGFPE.

The actual bug is that on Linux, this FPE is not getting mapped to Overflow; it works correctly on macOS. The problem is specific to Int64 values, so I suspect that we are seeing a different signal for division than for addition/multiplication. (For tagged integers, the Overflow in this case is caused by the addition used to retag the result).

Attached Files:

Changes

Field Old Value Date By
status_idOpen2020-07-10 15:12jhr
close_dateNone2020-07-10 15:12jhr
summaryPerform divide on Position.int crashs with FPE2020-07-10 15:12jhr
ResolutionAccepted As Bug2020-07-10 15:12jhr
assigned_tonone2020-07-01 19:45jhr
Machine ArchitectureOther2020-07-01 19:45jhr
Operating SystemNone2020-07-01 19:45jhr
ResolutionNone2020-07-01 19:45jhr
SeverityCritical2020-07-01 19:45jhr
Source (for reproduction) ```repro.sml val _ = (Position.fromLarge ~0x8000000000000000) div (Position.fromLarge ~1) ``` ```console $ sml -64 repro.sml Standard ML of New Jersey (64-bit) v110.97 [built: Tue May 12 00:16:59 2020] [opening basis/test/repro.sml] [autoloading] [library $SMLNJ-BASIS/basis.cm is stable] [library $SMLNJ-BASIS/(basis.cm):basis-common.cm is stable] [autoloading done] Floating point exception ``` 2020-07-01 19:45jhr