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 error in compiler's destructive update pass #9111

Open
wants to merge 2 commits into
base: maint-27
Choose a base branch
from

Conversation

frej
Copy link
Contributor

@frej frej commented Nov 26, 2024

As reported in #9100, an error in the compiler's destructive update pass could lead to crashes at runtime. This is a fix against the maintenance branch for OTP-27 . It is rooted in OTP-27.1.2, as usual it doesn't apply cleanly against master, so to help the person doing the forward merge, this gh9100 branch shows what should end up in master.

While refactoring the code responsible for merging patches to
different elements of a literal in function calls in order to reuse it
to solve issue erlang#9100, it was discovered that it only correctly handle
patches to top-level elements. If multiple elements of a tuple inside
another tuple was patched, it would crash.

This commit fixes the above mentioned bug and also refactors the code
to separate the parts that are specific to handle function arguments
from the parts that merges patches to literals.

The correctness of the refactoring is tested by already existing
tests. A test case verifying the fix will be added in the patch
addressing erlang#9100 as is it not worthwhile to spend the time to
construct a test-case testing each of the issues separately.
The code responsible for patching Phi-instructions could not handle
multiple patches to a single literal value, it silently discarded all
but one of the updates. This MR corrects this by merging patches,
using the same mechanism as used for patching function arguments.

Closes erlang#9100
Copy link
Contributor

github-actions bot commented Nov 26, 2024

CT Test Results

    2 files    324 suites   9m 23s ⏱️
  817 tests   815 ✅ 2 💤 0 ❌
5 420 runs  5 418 ✅ 2 💤 0 ❌

Results for commit 4d6e406.

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

@frej
Copy link
Contributor Author

frej commented Nov 26, 2024

The failing osv-scan test points to another project's build file which we apparently use as a smoke test. As this patch doesn't touch that part I'll ignore that failure.

@bjorng bjorng self-assigned this Nov 26, 2024
@bjorng bjorng added the team:VM Assigned to OTP team VM label Nov 26, 2024
@bjorng
Copy link
Contributor

bjorng commented Nov 26, 2024

Thanks! Added both branches to our daily builds.

@bjorng bjorng added the fix label Nov 26, 2024
@bjorng bjorng linked an issue Nov 26, 2024 that may be closed by this pull request
@bjorng
Copy link
Contributor

bjorng commented Nov 27, 2024

Merged to maint and master. This pull request will be closed when the next emergency patch is released.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segmentation fault on OTP27
2 participants