aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2019-06-26 09:26:41 +0200
committerJohn Högberg <[email protected]>2019-07-01 11:23:28 +0200
commita055766e0ca9d2b4a5007f00b007b087e06bc7a5 (patch)
treed14b2733fc2dae690dff8ef673ff0f664f8bd6e6 /lib/stdlib/test
parent620ac3e68c5bc8b36143965fcf2892a07dc005c4 (diff)
downloadotp-a055766e0ca9d2b4a5007f00b007b087e06bc7a5.tar.gz
otp-a055766e0ca9d2b4a5007f00b007b087e06bc7a5.tar.bz2
otp-a055766e0ca9d2b4a5007f00b007b087e06bc7a5.zip
erts: Fix integer overflow in list subtraction
CMP_TERM returned an `Sint`, which overflowed the `int` used in erl_rbtree for storing the comparison, causing list subtraction to behave strangely.
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r--lib/stdlib/test/lists_SUITE.erl11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/stdlib/test/lists_SUITE.erl b/lib/stdlib/test/lists_SUITE.erl
index 984b51e7ae..9a0fe4b5ca 100644
--- a/lib/stdlib/test/lists_SUITE.erl
+++ b/lib/stdlib/test/lists_SUITE.erl
@@ -2586,6 +2586,15 @@ subtract(Config) when is_list(Config) ->
[1,2,3,4,5,6,7,8,9,9999,10000,20,21,22] =
sub(lists:seq(1, 10000)++[20,21,22], lists:seq(10, 9998)),
+ %% ERL-986; an integer overflow relating to term comparison
+ %% caused subtraction to be inconsistent.
+ Ids = [2985095936,47540628,135460048,1266126295,240535295,
+ 115724671,161800351,4187206564,4178142725,234897063,
+ 14773162,6662515191,133150693,378034895,1874402262,
+ 3507611978,22850922,415521280,253360400,71683243],
+
+ [] = id(Ids) -- id(Ids),
+
%% Floats/integers.
[42.0,42.0] = sub([42.0,42,42.0], [42,42,42]),
[1,2,3,4,43.0] = sub([1,2,3,4,5,42.0,43.0], [42.0,5]),
@@ -2613,6 +2622,8 @@ subtract(Config) when is_list(Config) ->
ok.
+id(I) -> I.
+
sub_non_matching(A, B) ->
A = sub(A, B).