Skip to content

Commit 0729f49

Browse files
author
Erlang/OTP
committed
Merge branch 'john/erts/disable-unsafe-bs_append-optimization/ERIERL-1177/OTP-19462' into maint-25
* john/erts/disable-unsafe-bs_append-optimization/ERIERL-1177/OTP-19462: erts: Disable unsafe optimization in bs_append
2 parents 52ac03f + b4c3fe1 commit 0729f49

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

erts/emulator/beam/erl_bits.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,14 +1479,6 @@ erts_bs_append_checked(Process* c_p, Eterm* reg, Uint live,
14791479
}
14801480
}
14811481

1482-
if (build_size_in_bits == 0) {
1483-
if (HeapWordsLeft(c_p) < extra_words) {
1484-
(void) erts_garbage_collect(c_p, extra_words, reg, live+1);
1485-
bin = reg[live];
1486-
}
1487-
return bin;
1488-
}
1489-
14901482
if((ERTS_UINT_MAX - build_size_in_bits) < erts_bin_offset) {
14911483
c_p->fvalue = am_size;
14921484
c_p->freason = SYSTEM_LIMIT;
@@ -1573,10 +1565,6 @@ erts_bs_append_checked(Process* c_p, Eterm* reg, Uint live,
15731565
}
15741566
}
15751567

1576-
if (build_size_in_bits == 0) {
1577-
return bin;
1578-
}
1579-
15801568
if((ERTS_UINT_MAX - build_size_in_bits) < erts_bin_offset) {
15811569
c_p->fvalue = am_size;
15821570
c_p->freason = SYSTEM_LIMIT;

erts/emulator/test/bs_construct_SUITE.erl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,13 @@ do_something() ->
553553

554554
append_empty_is_same(Config) when is_list(Config) ->
555555
NonWritableBin = <<"123">>,
556-
true = erts_debug:same(NonWritableBin, append(NonWritableBin, <<>>)),
556+
557+
%% Should use erts_debug:same/2, but this was disabled in PR-9372
558+
%% (ERIERL-1177) because the optimization was unsafe.
559+
true = NonWritableBin =:= append(NonWritableBin, <<>>),
557560
WritableBin = <<(id(<<>>))/binary,0,1,2,3,4,5,6,7>>,
558-
true = erts_debug:same(WritableBin, append(WritableBin, <<>>)),
561+
true = WritableBin =:= append(WritableBin, <<>>),
562+
559563
ok.
560564

561565
append(A, B) ->

0 commit comments

Comments
 (0)