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

Use a custom disassembler based on beam_disasm #1

Open
the-mikedavis opened this issue Mar 21, 2023 · 1 comment
Open

Use a custom disassembler based on beam_disasm #1

the-mikedavis opened this issue Mar 21, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@the-mikedavis
Copy link
Member

Is your feature request related to a problem? Please describe.

Horus currently uses the beam_disasm module from the compiler application in Erlang/OTP to disassemble (convert BEAM chunks into instructions). beam_disasm had some bugs involving mistranslated instructions (for example erlang/otp#6447) which are papered over by Horus (for example see pass1_process_instructions/3). These mistranslations are fixed upstream but we must wait until Erlang/OTP 26 to take full advantage of the upstream fixes and drop compatibility code in Horus.

Also, beam_disasm in Erlang/OTP 26 cannot decode modules compiled with the Erlang/OTP 25 compiler. Erlang/OTP 26 introduced a new format for the Type BEAM chunk and also dropped all code for serializing and deserializing the version 1 type chunk from Erlang/OTP 25. This could happen again to this particular chunk or to any other BEAM chunk. A custom disassembler could support multiple BEAM chunk versions.

Describe the solution you'd like

Horus could implement a custom disassembler based on beam_disasm. This would allow us to fix the mistranslations in-tree and drop the compatibility code now. We could also support multiple BEAM chunk versions and have fine control over which Erlang/OTP versions are supported.

The downside to a custom disassembler is that it's more work to maintain. beam_disasm in Erlang/OTP provides a good guide but sometimes has bugs as mentioned. This part of Horus would need some work for every Erlang/OTP major release that introduces new instructions or changes the format of BEAM chunks. (Every major release since Erlang/OTP 20 has added new instructions.)

Describe alternatives you've considered

We could restrict the versions recommended for running Rabbit releases that include Horus and Khepri (see https://www.rabbitmq.com/which-erlang.html) to work around the version compatibility problem. The compatibility code for mistranslations could stay in-tree until Horus depends on Erlang/OTP 26 as a minimum.

Additional context

No response

@the-mikedavis the-mikedavis added the enhancement New feature or request label Mar 21, 2023
@the-mikedavis
Copy link
Member Author

The incompatibility between the OTP 25 compiler and OTP 26 beam_disasm was resolved and should be included in OTP 26.0: erlang/otp#7044

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant