diff options
author | John Högberg <[email protected]> | 2019-03-28 14:37:18 +0100 |
---|---|---|
committer | John Högberg <[email protected]> | 2019-03-28 14:37:18 +0100 |
commit | 2367dc1397063f78cc49eafa8e95e7e3493979d1 (patch) | |
tree | d9ff148dde49c5192d85818c853bbede45e671ce /erts/emulator/test | |
parent | 2f879097241d289e0100c7d1725485e2276a7f70 (diff) | |
parent | 0398c6868940af8561d3401c00441071c57d7ac5 (diff) | |
download | otp-2367dc1397063f78cc49eafa8e95e7e3493979d1.tar.gz otp-2367dc1397063f78cc49eafa8e95e7e3493979d1.tar.bz2 otp-2367dc1397063f78cc49eafa8e95e7e3493979d1.zip |
Merge branch 'john/erts/remove-destructive-bs_get_binary2/ERL-901'
* john/erts/remove-destructive-bs_get_binary2/ERL-901:
erts: Remove unsafe bs_get_binary2 optimization from loader
Diffstat (limited to 'erts/emulator/test')
-rw-r--r-- | erts/emulator/test/bs_match_misc_SUITE.erl | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/erts/emulator/test/bs_match_misc_SUITE.erl b/erts/emulator/test/bs_match_misc_SUITE.erl index 17759d78f3..cae4eb54d2 100644 --- a/erts/emulator/test/bs_match_misc_SUITE.erl +++ b/erts/emulator/test/bs_match_misc_SUITE.erl @@ -24,7 +24,7 @@ kenneth/1,encode_binary/1,native/1,happi/1, size_var/1,wiger/1,x0_context/1,huge_float_field/1, writable_binary_matched/1,otp_7198/1,unordered_bindings/1, - float_middle_endian/1]). + float_middle_endian/1,unsafe_get_binary_reuse/1]). -include_lib("common_test/include/ct.hrl"). @@ -36,7 +36,8 @@ all() -> [bound_var, bound_tail, t_float, little_float, sean, kenneth, encode_binary, native, happi, size_var, wiger, x0_context, huge_float_field, writable_binary_matched, - otp_7198, unordered_bindings, float_middle_endian]. + otp_7198, unordered_bindings, float_middle_endian, + unsafe_get_binary_reuse]. %% Test matching of bound variables. @@ -556,5 +557,21 @@ unordered_bindings(CompressedLength, HashSize, PadLength, T) -> Padding:PadLength/binary,PadLength>> = T, {Content,Mac,Padding}. +%% ERL-901: A load-time optimization assumed that match contexts had no further +%% uses when a bs_get_binary2 overwrote the match context's register, and +%% figured it would be safe to reuse the match context's memory for the +%% resulting binary. +%% +%% This is no longer safe as of OTP 22, as a match context may be reused after +%% being passed to another function. +unsafe_get_binary_reuse(Config) when is_list(Config) -> + <<_First, Rest/binary>> = <<"hello">>, + ubgr_1(Rest), + <<Second,_/bits>> = Rest, + $e = Second, + ok. + +ubgr_1(<<_CP/utf8, Rest/binary>>) -> id(Rest); +ubgr_1(_) -> false. id(I) -> I. |