diff options
author | Lukas Larsson <lukas@erlang.org> | 2021-09-02 09:08:06 +0200 |
---|---|---|
committer | Lukas Larsson <lukas@erlang.org> | 2021-09-02 09:08:06 +0200 |
commit | 98317a64fe29c227f21a9dc84d6bfee2d7f870ec (patch) | |
tree | 19b0bbd284d2cd7b14ccb4d88258fdd2af4a5cd0 | |
parent | ce6846aaaf9ba5f03f7fe7e612a02fb62c79d780 (diff) | |
parent | ce10900488ac79db29655e468a8f945846181bb2 (diff) | |
download | erlang-98317a64fe29c227f21a9dc84d6bfee2d7f870ec.tar.gz |
Merge branch 'lukas/erts/fix-re-copy-subbin-bug/OTP-17585' into maint
* lukas/erts/fix-re-copy-subbin-bug/OTP-17585:
erts: Make re copy small subbinaries
-rw-r--r-- | erts/emulator/beam/erl_bif_re.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/erts/emulator/beam/erl_bif_re.c b/erts/emulator/beam/erl_bif_re.c index ae0bc2ebe2..53634afcfe 100644 --- a/erts/emulator/beam/erl_bif_re.c +++ b/erts/emulator/beam/erl_bif_re.c @@ -1285,7 +1285,7 @@ re_run(Process *p, Eterm arg1, Eterm arg2, Eterm arg3, int first) } /* Optimized - if already in binary off heap, keep that and avoid - copying, also binary returns can be sub binaries in that case */ + copying, also binary returns can be sub binaries in that case. */ restart.flags = 0; if (is_binary(arg1)) { @@ -1300,7 +1300,10 @@ re_run(Process *p, Eterm arg1, Eterm arg2, Eterm arg3, int first) slength = binary_size(arg1); bptr = binary_val(real_bin); - if (bitsize != 0 || bitoffs != 0 || (*bptr != HEADER_PROC_BIN)) { + if (bitsize != 0 || bitoffs != 0 || slength <= ERL_ONHEAP_BIN_LIMIT) { + /* If this is an unaligned subbinary, + or the binary is smaller than the ERL_ONHEAP_BIN_LIMIT + we make a copy of the binary. */ goto handle_iolist; } pb = (ProcBin *) bptr; |