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

Test BEAM files without type information #7603

Merged
merged 1 commit into from
Sep 4, 2023

Conversation

bjorng
Copy link
Contributor

@bjorng bjorng commented Aug 30, 2023

Normally, all BEAM files created by OTP 25 and later have a "Type" chunk that contains type information. beam_lib:strip/1 will not discard the "Type" chunk, but build/release scripts that do their own custom stripping could accidentally delete the chunk.

Make sure to test that loading and executing BEAM files without type information works. Since there was an overrun-heap-and-stack bug (reported in #7292, fixed in #7581) when using the bit syntax, the bit syntax test suites seems to be appropriate to clone to new BEAM files without types.

Normally, all BEAM files created by OTP 25 and later have a "Type"
chunk that contains type information. `beam_lib:strip/1` will not
discard the "Type" chunk, but build/release scripts that do their own
custom stripping could accidentally delete the chunk.

Make sure to test that loading and executing BEAM files without type
information works. Since there was an overrun-heap-and-stack
bug (reported in erlang#7292, fixed in erlang#7581) when using the bit syntax, the
bit syntax test suites seems to appropriate to clone to new BEAM files
without types.
@bjorng bjorng added team:VM Assigned to OTP team VM enhancement testing currently being tested, tag is used by OTP internal CI labels Aug 30, 2023
@bjorng bjorng self-assigned this Aug 30, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Aug 30, 2023

CT Test Results

       4 files     425 suites   57m 52s ⏱️
2 166 tests 2 115 ✔️ 51 💤 0
6 877 runs  6 806 ✔️ 71 💤 0

Results for commit 3d04dbc.

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

@RobinMorisset
Copy link
Contributor

Is there an easy way to do such stripping of the Type chunk? I'd like to get it added as an option to erlfuzz.

@bjorng
Copy link
Contributor Author

bjorng commented Aug 30, 2023

When this PR has been merged you can do erlc +strip_types some_file.erl.

If you want to do it yourself, the basic procedure is the following:

    {ok,_Module,Chunks0} = beam_lib:all_chunks(Beam0),
    Chunks = [{Tag,Contents} || {Tag,Contents} <- Chunks0,
                                Tag =/= "Type"],
    {ok,Beam} = beam_lib:build_module(Chunks)

where Beam0 can either be the name of a BEAM file or the contents of a BEAM file as a binary. Beam is always a binary containg the stripped BEAM module.

@bjorng
Copy link
Contributor Author

bjorng commented Sep 1, 2023

In our daily builds, there were failed test cases in a few test runs (in 4 out of more than 50). The test cases failed because of uninitialised memory. The bug was hidden in most of the test runs because the freshly allocated memory happened to be zero. The bug is fixed in #7616.

@bjorng bjorng merged commit 0a6c695 into erlang:maint Sep 4, 2023
18 checks passed
@bjorng bjorng deleted the bjorn/erts/no-type-info branch September 4, 2023 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 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