Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@frej
Copy link
Contributor

@frej frej commented May 22, 2023

The beam_ssa_type pass deduces the type of variables from the result of relational operators. In the true-branch following a A '=:=' B, the variables A and B are deduced to be of the type beam_types:meet(type(A), type(B)) which is not necessarily true for bit strings. Bit strings are special in that nothing about their appendable-status can be deduced from a comparison. The only information gained is the size_unit. The appendable status is unchanged by the comparison.

This patch corrects a type inference bug for bit strings where a comparison would falsely set the appendable flag for non-appendable bit strings in the true-branch. The fix special-cases the type inferring following a =:= when one or both arguments are appendable by clearing the appendable status, calculating the resulting type and then restoring the appendable-status of the variables.
[edited to match updated commit message]

@frej frej force-pushed the frej/fix-binary-construction-crash branch from 3c9614d to 7a5f088 Compare May 22, 2023 13:49
@github-actions
Copy link
Contributor

github-actions bot commented May 22, 2023

CT Test Results

       2 files     296 suites   13m 21s ⏱️
   776 tests    774 ✔️ 2 💤 0
4 904 runs  4 902 ✔️ 2 💤 0

Results for commit fd735d6.

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

@bjorng bjorng self-assigned this May 23, 2023
@bjorng bjorng added team:VM Assigned to OTP team VM fix labels May 23, 2023
@bjorng bjorng added the testing currently being tested, tag is used by OTP internal CI label May 23, 2023
@bjorng
Copy link
Contributor

bjorng commented May 24, 2023

We want to include this PR in an emergency patch release. Please rebase your branch like this and force-push:

git rebase --onto OTP-26.0 HEAD~1

The beam_ssa_type pass deduces the type of variables from the result
of relational operators. In the true-branch following a `A '=:=' B`,
the variables `A` and `B` are deduced to be of the type
`beam_types:meet(type(A), type(B))` which is not necessarily true for
bit strings. Bit strings are special in that nothing about their
appendable-status can be deduced from a comparison. The only
information gained is the size_unit. The appendable status is
unchanged by the comparison.

This patch corrects a type inference bug for bit strings where a
comparison would falsely set the appendable flag for non-appendable
bit strings in the true-branch. The fix special-cases the type
inferring following a `=:=` when one or both arguments are appendable
by clearing the appendable status, calculating the resulting type and
then restoring the appendable-status of the variables.
@frej frej force-pushed the frej/fix-binary-construction-crash branch from 7a5f088 to fd735d6 Compare May 24, 2023 06:29
@frej
Copy link
Contributor Author

frej commented May 24, 2023

Please rebase your branch like this and force-push:

Done.

@bjorng bjorng merged commit 830c717 into erlang:maint May 24, 2023
@frej frej deleted the frej/fix-binary-construction-crash branch May 24, 2023 10:22
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.

2 participants