# OTP 25.0-rc3 (release Candidate 3) is released

**URL:** <https://erlangforums.com/t/otp-25-0-rc3-release-candidate-3-is-released/1317>\
**Category:** Erlang News\
**Tags:** erlang-release\
**Created:** [April 13, 2022, 12:46pm UTC](https://erlangforums.com/t/otp-25-0-rc3-release-candidate-3-is-released/1317 "2022-04-13T12:46:27Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![RoadRunnr](https://erlangforums.com/user_avatar/erlangforums.com/roadrunnr/32/1397_2.png) [@RoadRunnr](https://erlangforums.com/u/RoadRunnr)\
**Post date:** [May 2, 2022, 5:31pm UTC](https://erlangforums.com/t/otp-25-0-rc3-release-candidate-3-is-released/1317/22 "2022-05-02T17:31:52Z")

</div>

The crash only occurs when using qemu user mode emulation (by just running `./bin/erl -emu_flavor jit`). In that mode debugging like you suggested does not work at all because ptrace is not supported. I tried using qemu gdbstub, but that does also just segfaults.

In qemu system mode the jit version that was compile within that VM works. When I try to run the binaries produced in the VM in qemu user mode, it goes to 100% CPU load and just does nothing (no CLI prompt, no other output).

The binaries compiled with the user mode emulation work fine when moving them into the VM image and running them under system emulation.

The root images for both version are the same. So the tooling for both builds was identical.

The host CPU is a Intel Core 7, so nothing spectacular.  
QEMU is 6.2 (Ubuntu Jammy host) and Linux 5.17.5-051705-generic.

Reproducing this should be simple. Enable QEMU user mode emulation for aarch64, grab the Alpine 3.15.4 AArch64 root tar, extranct, chroot to it and build otp in it.

I’m going to try this with a Debian AArch64 root to see if there is difference in muslc vs. glibc based systems.

---

<div class="post-metadata">

**Author:** ![jhogberg](https://erlangforums.com/user_avatar/erlangforums.com/jhogberg/32/179_2.png) [@jhogberg](https://erlangforums.com/u/jhogberg)\
**Post date:** [May 2, 2022, 8:12pm UTC](https://erlangforums.com/t/otp-25-0-rc3-release-candidate-3-is-released/1317/23 "2022-05-02T20:12:48Z")

</div>

I think I see why it breaks under user-mode but not system emulation. Can you check if it works with this branch?

> **[GitHub - jhogberg/otp at john/jit/aarch64-qemu-debugging](https://github.com/jhogberg/otp/tree/john/jit/aarch64-qemu-debugging)**
>
> john/jit/aarch64-qemu-debugging

---

<div class="post-metadata">

**Author:** ![RoadRunnr](https://erlangforums.com/user_avatar/erlangforums.com/roadrunnr/32/1397_2.png) [@RoadRunnr](https://erlangforums.com/u/RoadRunnr)\
**Post date:** [May 3, 2022, 8:08am UTC](https://erlangforums.com/t/otp-25-0-rc3-release-candidate-3-is-released/1317/24 "2022-05-03T08:08:28Z")

</div>

That branch successfully compiles and I get a running Erlang shell from `bin/erl`.

Would you be inclined to accept a PR that adds a Aarch64 build based on QEMU user mode to the OTP github build actions?

---

<div class="post-metadata">

**Author:** ![jhogberg](https://erlangforums.com/user_avatar/erlangforums.com/jhogberg/32/179_2.png) [@jhogberg](https://erlangforums.com/u/jhogberg)\
**Post date:** [May 3, 2022, 10:17am UTC](https://erlangforums.com/t/otp-25-0-rc3-release-candidate-3-is-released/1317/25 "2022-05-03T10:17:07Z")

</div>

> [@RoadRunnr](#):
>
> That branch successfully compiles and I get a running Erlang shell from `bin/erl`.

Thanks, I’ve found a bug in QEMU that explains this. The gist of it is:

Instead of interpreting guest code, QEMU dynamically translates it to the host architecture. When the guest overwrites code for one reason or another, the translation is invalidated and redone if needed.

Our JIT:ed code is mapped in two regions to work in the face of W^X restrictions: one executable but not writable, and one writable but not executable. Both of these regions point to the same physical memory and writes to the writable region are “magically” reflected in the executable one.

I would’ve expected QEMU to honor the `IC IVAU` / `ISB` instructions we use to tell the processor that we’ve altered code at a particular address, but for some reason [QEMU just ignores them](https://github.com/qemu/qemu/blob/f5643914a9e8f79c606a76e6a9d7ea82a3fc3e65/target/arm/helper.c#L4829) and relies entirely on trapping writes to previously translated code.

In system mode QEMU emulates the MMU and sees that these two regions point at the same memory, and has no problem invalidating the executable region after writing to the writable region.

In user mode it instead calls `mprotect(..., PROT_READ)` on all code regions it has translated, and invalidates translations in the signal handler. The problem is that we never write to the executable region – just the writable one – so the code doesn’t get invalidated.

> [@RoadRunnr](#):
>
> Would you be inclined to accept a PR that adds a Aarch64 build based on QEMU user mode to the OTP github build actions?

Sure, if it runs quickly enough I’m open to adding it once they fix this bug.

---

<div class="post-metadata">

**Author:** ![mmin](https://erlangforums.com/user_avatar/erlangforums.com/mmin/32/2193_2.png) [@mmin](https://erlangforums.com/u/mmin)\
**Post date:** [May 4, 2022, 4:43pm UTC](https://erlangforums.com/t/otp-25-0-rc3-release-candidate-3-is-released/1317/26 "2022-05-04T16:43:57Z")

</div>

I want to try `maybe_expr` feature introduced in OTP 25.0. I installed 25.0-rc3 locally using `kerl` and when I run `r3 compile` or `r3 shell` I get no errors at all. However, when I try to run (in rebar3 shell, OTP 25, ERTS v13.0) exported functions from module using `maybe` expression I get the following error:

`Loading of /home/marko/<project_root>/_build/default/lib/<project_name>/ebin/pfun.beam failed: not_allowed`  
`** exception error: undefined function pfun:<fun_i'm_trying_to_run>`.

In `pfun` module I’ve got the following attributes:  
`-feature(maybe_expr, enable).`  
`-compile({feature, maybe_expr, enable}).`

Also, `erl_opts` in `rebar.config` contains `{feature, maybe_expr, enable}`.  
Any idea of what is wrong here?

---

<div class="post-metadata">

**Author:** ![sg2342](https://erlangforums.com/user_avatar/erlangforums.com/sg2342/32/1233_2.png) [@sg2342](https://erlangforums.com/u/sg2342)\
**Post date:** [May 4, 2022, 4:56pm UTC](https://erlangforums.com/t/otp-25-0-rc3-release-candidate-3-is-released/1317/27 "2022-05-04T16:56:24Z")

</div>

i ran into the same issue and worked around it by:

1. `-enable-feature maybe_expr` in `config/vm.args` and
2. `env ERL_FLAGS="-args_file config/vm.args" rebar3 shell`

you can also issue ` erl_features:enable_feature(maybe_expr).` in `rebar3 shell` before loading the `pfun` module.

---

<div class="post-metadata">

**Author:** ![cons](https://erlangforums.com/user_avatar/erlangforums.com/cons/32/195_2.png) [@cons](https://erlangforums.com/u/cons)\
**Post date:** [May 5, 2022, 6:22am UTC](https://erlangforums.com/t/otp-25-0-rc3-release-candidate-3-is-released/1317/28 "2022-05-05T06:22:57Z")

</div>

The option `-enable-feature maybe_expr` has to be given to the runtime to allowing loading modules that have been compiled with the feature enabled. This is to make an active decision in allowing experimental features.  
While `erl_features:enable_feature/1` is available in RC3, it will not be available in the final release of OTP25. Enabling features in the runtime is only allowed during startup and changing (enabling/disabling) is not allowed thereafter.  
Full documentation for the features support will be included with OTP25.

---

<div class="post-metadata">

**Author:** ![cons](https://erlangforums.com/user_avatar/erlangforums.com/cons/32/195_2.png) [@cons](https://erlangforums.com/u/cons)\
**Post date:** [May 5, 2022, 6:49am UTC](https://erlangforums.com/t/otp-25-0-rc3-release-candidate-3-is-released/1317/29 "2022-05-05T06:49:32Z")

</div>

> [@mmin](#):
>
> In `pfun` module I’ve got the following attributes:  
> `-feature(maybe_expr, enable).`  
> `-compile({feature, maybe_expr, enable}).`

Note that you only need one of these and using the `-feature` directive is the preferred use. To be honest, while a `-compile` attribute is allowed anywhere in a file, the enabling and disabling of features is only allowed in a prefix of the file, so using `-compile` to enable/disable a feature anywhere might have unexpected results, i.e., I have to test and fix this.

[Previous page](https://erlangforums.com/t/otp-25-0-rc3-release-candidate-3-is-released/1317.md?page=1)
