stdlib: Fix unicode_util:gc/1 breaking binary continuations - #11464
Merged
dgud merged 1 commit intoAug 19, 2026
Conversation
Contributor
CT Test Results 2 files 100 suites 1h 9m 17s ⏱️ Results for commit 04fa12b. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts
// Erlang/OTP Github Action Bot |
garazdawi
previously approved these changes
Aug 11, 2026
The gc/1 fast-path for $\r was calling cp(R0) and returning
[CP|T] when \r was not followed by \n. This "exploded" the
binary tail into mixed chardata (integers + binary fragments),
which downstream functions in string.erl (bin_search_loop,
bin_search_inv_n) could not handle — they expect
[BinR|Cont] when is_binary(BinR).
This caused string:trim/3 to return wrong results or crash
with {case_clause,[]} when trimming strings containing binaries
followed by another list element, and the binary contained $\r
not followed by $\n.
Fix: return the original input (Str) instead of [CP|cp(R0)],
consistent with what gc_1/1 already does.
Closes erlang#11380
dgud
force-pushed
the
dgud/string/bin_search/GH-11380/OTP-20296
branch
from
August 11, 2026 13:05
9cfb9a0 to
04fa12b
Compare
garazdawi
approved these changes
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The gc/1 fast-path for $\r was calling cp(R0) and returning [CP|T] when \r was not followed by \n. This "exploded" the binary tail into mixed chardata (integers + binary fragments), which downstream functions in string.erl (bin_search_loop, bin_search_inv_n) could not handle — they expect
[BinR|Cont] when is_binary(BinR).
This caused string:trim/3 to return wrong results or crash with {case_clause,[]} when trimming strings containing binaries followed by another list element, and the binary contained$\r not followed by $ \n.
Fix: return the original input (Str) instead of [CP|cp(R0)], consistent with what gc_1/1 already does.
Closes #11380