Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

erts: fix sub binary bug in erl_bif_re #9478

Conversation

frazze-jobb
Copy link
Contributor

Closes GH-9438

@frazze-jobb frazze-jobb added team:VM Assigned to OTP team VM fix labels Feb 24, 2025
@frazze-jobb frazze-jobb requested a review from sverker February 24, 2025 10:48
@frazze-jobb frazze-jobb self-assigned this Feb 24, 2025
Copy link
Contributor

github-actions bot commented Feb 24, 2025

CT Test Results

    4 files    227 suites   1h 55m 25s ⏱️
3 671 tests 3 578 ✅  93 💤 0 ❌
4 775 runs  4 659 ✅ 116 💤 0 ❌

Results for commit 31849d0.

♻️ 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

sverker
sverker previously approved these changes Feb 24, 2025
@@ -629,6 +629,7 @@ static bool get_iolist_as_bytes(Eterm iolist,

ERTS_GET_BITSTRING(iolist, *bytes_p, bit_offs, bit_sz);
if (!BIT_OFFSET(bit_offs) && !TAIL_BITS(bit_sz)) {
*bytes_p += BYTE_OFFSET(bit_offs);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!
A testcase that tests regex as sub-binaries would be good. Maybe also test byte unaligned regex strings even if that is very unlikely to be used in practice.
Do we even have a testcase for subject strings as sub-binaries?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, added tests

@frazze-jobb frazze-jobb requested a review from sverker February 25, 2025 15:30
@frazze-jobb frazze-jobb added the testing currently being tested, tag is used by OTP internal CI label Feb 25, 2025
@frazze-jobb frazze-jobb changed the title erts: fix binary offset bug in erl_bif_re erts: fix sub binary bug in erl_bif_re Feb 26, 2025
sverker
sverker previously approved these changes Feb 26, 2025
Comment on lines 1133 to 1138
try
nomatch = re:run(Subject, Bin2, [{capture, none}])
catch error:badarg ->
%% *** argument 2: neither an iodata term nor a compiled regular expression
ok
end.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be something like
ok = try ... catch error:badarg -> ok end.
to make sure it actually raised a badarg.

<<0:1, Subject2/binary>> = Bin2 = <<0:1,"::1">>,
match = re:run(Subject2, REC, [{capture, none}]),
match = re:run(Subject2, RE, [{capture, none}]),
try
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@frazze-jobb frazze-jobb force-pushed the frazze/erts/erl_re_bif_binary_offset_bug/GH-9438/OTP-19507 branch from bb104d9 to 31849d0 Compare February 26, 2025 11:49
@frazze-jobb frazze-jobb merged commit 0e7082b into erlang:master Feb 26, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OTP-28.0-rc1: re:run failes on some binaries, but not on others
2 participants