Skip to content

beam_ssa_private_append: Fix crash on oddly structured code #7143

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

Conversation

jhogberg
Copy link
Contributor

The private append pass didn't expect to append anything to literals other than <<>>. Rare interactions with the type or bool passes could sneak in things like atoms in unexpected places, crashing the pass.

@frej

The private append pass didn't expect to append anything
to literals other than `<<>>`. Rare interactions with the type
or bool passes could sneak in things like atoms in unexpected
places, crashing the pass.
@jhogberg jhogberg added the team:VM Assigned to OTP team VM label Apr 21, 2023
@jhogberg jhogberg self-assigned this Apr 21, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 21, 2023

CT Test Results

       2 files     296 suites   11m 55s ⏱️
   771 tests    769 ✔️ 2 💤 0
4 861 runs  4 859 ✔️ 2 💤 0

Results for commit d50da87.

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

Copy link
Contributor

@frej frej left a comment

Choose a reason for hiding this comment

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

LGTM if @jhogberg agrees that this small change is the right thing this late in the release process.

@@ -565,6 +565,8 @@ patch_literal_term(<<>>, self, Cnt0) ->
{V,Cnt} = new_var(Cnt0),
I = #b_set{op=bs_init_writable,dst=V,args=[#b_literal{val=256}]},
{V, [I], Cnt};
patch_literal_term(Lit, self, Cnt) ->
Copy link
Contributor

@frej frej Apr 24, 2023

Choose a reason for hiding this comment

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

This fixes the symptom, but it's not the right fix as we should already have discovered that this isn't possible, i.e. add_literal/3 should never get to add the "patchee" to the set of literals to patch.

For the work I'm currently doing I have refactored add_literal/3 to do a validity check, so we never add something which later on turns out to be impossible. I could try to backport that work, but as it's a larger patch, this is probably correct the conservative thing to do for R26.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather keep things small this late in the release process, but then again it might end up biting us later. How large do you think the add_literal/3 change would be?

Copy link
Contributor

Choose a reason for hiding this comment

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

It will require adding additional arguments to add_literal/3 and thus changing all call sites.

Considering that the only drawback of your fix is that we may keep too many literals around and spend some time trying to patch them before giving up, I'm perfectly happy with your patch.

The no-non-patchable-literals refinement can wait until R27 and the added clause will show up as not visited while running coverage, so there is little risk that it will remain when merging the refined stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'll go ahead with this then :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

[erlc] internal error in sub pass ssa_opt_private_append
2 participants