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

Fix bug in private-append transform #7207

Merged
merged 2 commits into from
May 5, 2023

Conversation

frej
Copy link
Contributor

@frej frej commented May 4, 2023

No description provided.

frej added 2 commits May 4, 2023 14:36
Fix a bug in the SSA-checker where it trashes the environment after
matching a literal bitstring.
This change stops the compiler from generating invalid code when
bs_create_bin is given a literal <<>> as its first fragment. As the
type analyzer considers a literal <<>> an appendable bitstring, code
sequences such as:

_6 = bs_create_bin `append`, `[8,{segment,1}]`, `<<>>`, `all`
...
_14 = bs_create_bin `append`, `[8,{segment,1}]`, _6, `all`

would be rewritten to:

_6 = bs_create_bin `private_append`, `[8,{segment,1}]`, `<<>>`, `all`
...
_14 = bs_create_bin `private_append`, `[8,{segment,1}]`, _6, `all`

which is not legal, as private_append on a literal will crash the
runtime system.

By inserting a bs_init_writable in front of bs_create_bin instructions
with a literal <<>> as the first fragment, and then using the freshly
created writable binary instead of the literal, the code sequence
becomes valid:

_1 = bs_init_writable `256`
_6 = bs_create_bin `private_append`, `[8,{segment,1}]`, _1, `all`
...
_14 = bs_create_bin `private_append`, `[8,{segment,1}]`, _6, `all`
@github-actions
Copy link
Contributor

github-actions bot commented May 4, 2023

CT Test Results

       2 files     296 suites   11m 39s ⏱️
   776 tests    774 ✔️ 2 💤 0
4 896 runs  4 894 ✔️ 2 💤 0

Results for commit 5277d99.

♻️ 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 4, 2023
@bjorng bjorng added team:VM Assigned to OTP team VM fix testing currently being tested, tag is used by OTP internal CI labels May 4, 2023
@bjorng
Copy link
Contributor

bjorng commented May 4, 2023

Thanks! Added to our daily builds.

@bjorng bjorng merged commit 2fedd1f into erlang:master May 5, 2023
@frej frej deleted the frej/private-append-fix branch May 8, 2023 06:19
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