diff options
author | Raimo Niskanen <[email protected]> | 2017-08-24 09:37:16 +0200 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2017-08-24 09:37:16 +0200 |
commit | 710f9437498a8a9df62a6c7cecd6eb632561754b (patch) | |
tree | 00d7dc89d265b8e4607b22f78445dee811834876 /erts/emulator/test/bs_construct_SUITE.erl | |
parent | d50bc5031eb0889c894bf20f5206cfc06162f30a (diff) | |
parent | 41878bba817fc2ec9e08529afe19c2655742dbd1 (diff) | |
download | otp-710f9437498a8a9df62a6c7cecd6eb632561754b.tar.gz otp-710f9437498a8a9df62a6c7cecd6eb632561754b.tar.bz2 otp-710f9437498a8a9df62a6c7cecd6eb632561754b.zip |
Merge branch 'maint-20' into maint
* maint-20:
Updated OTP version
Prepare release
Accept non-binary options as socket-options
Bump version
Fix broken handling of default values in extensions for PER
compiler: Fix live regs update on allocate in validator
Take fail labels into account when determining liveness in block ops
Check for overflow when appending binaries, and error out with system_limit
Diffstat (limited to 'erts/emulator/test/bs_construct_SUITE.erl')
-rw-r--r-- | erts/emulator/test/bs_construct_SUITE.erl | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/erts/emulator/test/bs_construct_SUITE.erl b/erts/emulator/test/bs_construct_SUITE.erl index b79f4b995d..ce50bcdd86 100644 --- a/erts/emulator/test/bs_construct_SUITE.erl +++ b/erts/emulator/test/bs_construct_SUITE.erl @@ -905,14 +905,28 @@ bs_add_overflow(_Config) -> _ when Memsize < (2 bsl 30) -> {skip, "Less then 2 GB of memory"}; 4 -> - Large = <<0:((1 bsl 30)-1)>>, - {'EXIT',{system_limit,_}} = - (catch <<Large/bits, Large/bits, Large/bits, Large/bits, - Large/bits, Large/bits, Large/bits, Large/bits, - Large/bits>>), + {'EXIT', {system_limit, _}} = (catch bs_add_overflow_signed()), + {'EXIT', {system_limit, _}} = (catch bs_add_overflow_unsigned()), ok end. +bs_add_overflow_signed() -> + %% Produce a large result of bs_add that, if cast to signed int, would + %% overflow into a negative number that fits a smallnum. + Large = <<0:((1 bsl 30)-1)>>, + <<Large/bits, Large/bits, Large/bits, Large/bits, + Large/bits, Large/bits, Large/bits, Large/bits, + Large/bits>>. + +bs_add_overflow_unsigned() -> + %% Produce a large result of bs_add that goes beyond the limit of an + %% unsigned word. This used to succeed but produced an incorrect result + %% where B =:= C! + A = <<0:((1 bsl 32)-8)>>, + B = <<2, 3>>, + C = <<A/binary,1,B/binary>>, + true = byte_size(B) < byte_size(C). + id(I) -> I. memsize() -> |