Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
eb8e404
Add support for process aliases
mat-hek Jun 2, 2026
a4575d4
Fix data race in process alias message send
bettio Jun 2, 2026
b116c26
Make reply_demonitor alias remove the monitor on reply
bettio Jun 2, 2026
7b2ec4b
Drop OTP < 26 gating from alias tests
bettio Jun 2, 2026
0d12ca2
Deactivate alias on automatic monitor removal at 'DOWN'
bettio Jun 3, 2026
a5642b2
Release process lock on monitor/3 kind-mismatch error
bettio Jun 3, 2026
7b95b6e
Reserve monitor/3 and spawn_opt result space before publishing monitors
bettio Jun 3, 2026
1741064
Preserve send order for alias messages
bettio Jun 3, 2026
0d3b048
Compare local process references consistently against external refs
bettio Jun 3, 2026
783976b
Reject out-of-range process id when decoding a process reference
bettio Jun 3, 2026
db4bc4f
Return a real alias from monitor/3 on the self and noproc paths
bettio Jun 3, 2026
a7d314e
Document that sends to non-alias references are dropped
bettio Jun 3, 2026
d1f71ab
Initialize the trailing word of a 32-bit resource reference
bettio Jun 3, 2026
94e60fe
Add missing break to the CONTEXT_MONITOR_RESOURCE case in context_dem…
bettio Jun 3, 2026
e58781e
Remove never-scheduled processes from the scheduler queue on destroy
bettio Jun 4, 2026
3ad275f
Install the spawn_opt link only after spawn can no longer fail
bettio Jun 4, 2026
b5883e4
Install nothing when monitoring self, like OTP
bettio Jun 4, 2026
8f19764
Compare links against the initial set in the spawn_opt atomicity test
bettio Jun 4, 2026
b1df67a
Free never-published monitors through monitor_destroy
bettio Jun 4, 2026
9fb87a9
Const-qualify RefData parameters and document the reference helpers
bettio Jun 4, 2026
28d4ef0
Accept alias references in the erlang.erl send destination type
bettio Jun 4, 2026
5d05ac6
Add process aliases to the changelog
bettio Jun 4, 2026
4e1ac2e
Remove the unused RefType enum
bettio Jun 4, 2026
6491486
Typedef the alias type enum as context_monitor_alias_type_t
bettio Jun 4, 2026
a4bdbc7
Drop the module prefix from the static outer-list helper
bettio Jun 4, 2026
d9ea591
Process outer-list alias messages in received order
bettio Jun 6, 2026
0218ade
Build the self monitor reference with term_from_ref_ticks
bettio Jun 6, 2026
5501047
Reject the invalid owner process id when decoding a process reference
bettio Jun 9, 2026
7efc571
Compare process references in wire word order in term_compare
bettio Jun 9, 2026
d6386a9
Free the alias monitor through its container pointer in context_add_m…
bettio Jun 9, 2026
b5e5d92
Raise badarg on a malformed spawn_opt monitor option
bettio Jun 9, 2026
0a977e7
Deactivate the alias on a same-batch DOWN before delivering alias mes…
bettio Jun 9, 2026
fe199be
Re-type alias messages in place instead of copying
bettio Jun 9, 2026
7bf7943
Note the unchecked mailbox_send_monitor_signal OOM with a FIXME
bettio Jun 9, 2026
5d6a1ea
Fix the REF_SIZE deprecation pragma to emit a proper warning
bettio Jun 9, 2026
4120a28
Restore the TODO comment spacing in the esp32 network driver
bettio Jun 9, 2026
2884d98
Return false from unalias/1 on an external reference
bettio Jun 9, 2026
b9b7aa0
Echo the io request ReplyAs term back verbatim from the console
bettio Jun 9, 2026
a3a86b5
Reject process aliases as select handles
bettio Jun 9, 2026
17814a1
Make the alias tests deterministic on slow runners
bettio Jun 9, 2026
716e0a9
Tidy the alias tests
bettio Jun 9, 2026
763a873
Rename the spawn_monitor test helper to spawn_opt_monitor
bettio Jun 9, 2026
0e3df1f
Describe the alias modes precisely in the monitor/3 documentation
bettio Jun 9, 2026
e3207bd
Add alias coverage for map and ets keys and demonitor flush
bettio Jun 9, 2026
9e15abd
Skip alias lookups for processes without active aliases
bettio Jun 10, 2026
14a5259
Add alias coverage for duplicate options and a name-of-self monitor
bettio Jun 10, 2026
ddbdb2b
Implement erlang:alias/1
bettio Jun 10, 2026
ae038ff
Return the message from a JIT send to a dropped reference
bettio Jun 10, 2026
efdd536
Pad process references instead of resource references on 32-bit
bettio Jun 10, 2026
54266fa
DO NOT SQUASH: Encode the DOWN ref shape in the monitor type instead …
bettio Jun 10, 2026
610a5b1
Saturate active_alias_count instead of wrapping at 65536 aliases
bettio Jun 10, 2026
5a1fdf8
Deliver incoming distributed alias sends to the local alias
bettio Jun 10, 2026
d6769df
Document alias limitations and the REF_SIZE deprecation
bettio Jun 10, 2026
ba610a2
Process the outer mailbox list in one pass when no alias is active
bettio Jun 11, 2026
30509f0
Reserve the full reply size in the console gen_call error paths
bettio Jun 11, 2026
230fb29
Migrate the USB CDC drivers off the deprecated REF_SIZE
bettio Jun 12, 2026
533ca18
Move the remote alias limitation to the distributed Erlang page
bettio Jun 12, 2026
514d1d5
Add alias coverage for dead owners, sender races and decode bounds
bettio Jun 12, 2026
2178a9d
Return int32_t from the process reference pid accessor
bettio Jun 12, 2026
e328f0b
Free dropped alias messages instead of deferring them to GC
bettio Jun 12, 2026
c63f980
Document the drain-time processes_table lock invariant
bettio Jun 12, 2026
e406a4e
Raise the same-batch relay wait bound for valgrind schedulers
bettio Jun 12, 2026
32f3679
Make the unsupported-option doc notes stand out
bettio Jun 15, 2026
7623119
Drop the narration above the decoded process-id check
bettio Jun 15, 2026
9c193d8
Test the term ordering of alias references
bettio Jun 15, 2026
6794cb7
Drop the wire-order narration in the reference comparison
bettio Jun 15, 2026
c539f6f
Check the process reference wire bytes and block round-trip folding
bettio Jun 15, 2026
c4ffdcb
Remove the OTP version note from the process aliases changelog entry
bettio Jun 15, 2026
78b010e
Check for a reference before the alias branch in the send paths
bettio Jun 15, 2026
b95b07d
Saturate the active alias count in 8 bits without a separate flag
bettio Jun 15, 2026
a75c8ea
Reserve the exact reference size for the terminate-path DOWN message
bettio Jun 15, 2026
3e0b828
Drop the redundant pid/port check on a registered send target in jit_…
bettio Jun 15, 2026
251c7b2
Raise unsupported for the alias/1 priority option
bettio Jun 16, 2026
ca610b0
Mark the process-reference error paths as unlikely
bettio Jun 16, 2026
f4cf48b
Trim redundant and obvious comments added by the alias work
bettio Jun 16, 2026
233e4d6
Drop em-dashes from the alias comments for a plainer style
bettio Jun 16, 2026
bbb1547
Name the active_alias_count saturation sentinel
bettio Jun 16, 2026
91cb08d
Name the expected control arity in the alias-send dist handler
bettio Jun 17, 2026
bc870f9
Shorten the mailbox_send_monitor_signal allocation-failure FIXME
bettio Jun 17, 2026
cd94f03
Decouple the alias-blind mailbox drain from Context
bettio Jun 17, 2026
9a72db5
Trim comments that restate a contract or nearby comment
bettio Jun 17, 2026
b54621f
Cut over-narrating comments in the alias tests
bettio Jun 17, 2026
f7eccdc
Trim the select-handle alias-rejection comments
bettio Jun 17, 2026
8362d04
Split a semicolon-joined comment in the alias monitor test
bettio Jun 17, 2026
25365fe
Trim the console reply comments to their non-obvious facts
bettio Jun 17, 2026
0a949b6
Trim over-narrating comments across the alias C code
bettio Jun 17, 2026
6990a17
reformat tests/erlang_tests/test_monitor.erl
bettio Jun 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `"USB_SERIAL_JTAG"` peripheral to the ESP32 `uart` module on chips with a built-in
USB-Serial-JTAG controller (C3/C5/C6/C61/H2/H21/H4/P4/S3)
- Added support for the `safe` option in `erlang:binary_to_term/2`
- Added support for process aliases: `erlang:alias/0,1`, `erlang:unalias/1`,
`erlang:monitor/3` with the `{alias, Mode}` option, `spawn_opt` `{monitor, MonitorOpts}` and
sending to an alias reference
- Added xtensa JIT backend for esp32 platform
- Added support for configuring pins and width for sdmmc on ESP32
- Added support for map comprehensions
Expand All @@ -43,6 +46,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
longer lines return `{error, {parser, {line_too_long, Prefix}}}` with the first 128 bytes of
the offending line. Callers whose upstream servers emit unusually large headers must account
for this limit
- Deprecated the C macro `REF_SIZE`: use `TERM_BOXED_REFERENCE_SHORT_SIZE` for references built
from ref ticks, `TERM_BOXED_REFERENCE_PROCESS_SIZE` for process references (aliases), or
`TERM_BOXED_REFERENCE_MAX_SIZE` to fit any reference. `REF_SIZE` still expands to the short
reference size, but now emits a compiler warning

### Removed
- Removed `ahttp_client` support for obsolete line folding (RFC 9112 §5.2); folded header and
Expand Down
7 changes: 7 additions & 0 deletions doc/src/distributed-erlang.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,11 @@ RPC (remote procedure call) from Erlang/OTP to AtomVM is also supported.

Shell requires several OTP standard library modules. See [the example project](https://github.com/pguyot/atomvm_shell).

## Known Issues & Limitations

- Sending to a remote process alias is not supported: a message sent from AtomVM to an alias
(a reference) of another node is silently dropped instead of being routed over distribution.
The other direction works: a message sent from a remote BEAM node to an alias of an AtomVM
process is delivered.

Please do not hesitate to file issues or pull requests for additional features.
95 changes: 86 additions & 9 deletions libs/estdlib/src/erlang.erl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
make_ref/0,
send/2,
monitor/2,
monitor/3,
demonitor/1,
demonitor/2,
exit/1,
Expand Down Expand Up @@ -174,7 +175,10 @@
tl/1,
trunc/1,
tuple_size/1,
tuple_to_list/1
tuple_to_list/1,
alias/0,
alias/1,
unalias/1
]).

-export_type([
Expand Down Expand Up @@ -212,12 +216,14 @@
| {max_heap_size, pos_integer()}
| {atomvm_heap_growth, atomvm_heap_growth_strategy()}
| link
| monitor.
| monitor
| {monitor, [monitor_option()]}.

-type send_destination() ::
pid()
| port()
| atom().
| atom()
| reference().

% Current type until we make these references
-type resource() :: binary().
Expand All @@ -238,6 +244,8 @@
-type raise_stacktrace() ::
[{module(), atom(), arity() | [term()]} | {function(), arity() | [term()]}] | stacktrace().

-type monitor_option() :: {alias, explicit_unalias | demonitor | reply_demonitor}.

%%-----------------------------------------------------------------------------
%% @param Time time in milliseconds after which to send the timeout message.
%% @param Dest Pid or server name to which to send the timeout message.
Expand Down Expand Up @@ -1222,8 +1230,10 @@ spawn_monitor(Module, Function, Args) ->

%%-----------------------------------------------------------------------------
%% @param Function function to create a process from
%% @param Options additional options.
%% @returns pid of the new process
%% @param Options additional options, see `spawn_option()'. With `monitor'
%% or `{monitor, MonitorOpts}' the new process is also monitored, see
%% `monitor/3' for the monitor options.
%% @returns pid of the new process, or `{Pid, MonitorRef}' when monitoring
%% @doc Create a new process.
%% @end
%%-----------------------------------------------------------------------------
Expand All @@ -1236,8 +1246,10 @@ spawn_opt(_Name, _Options) ->
%% @param Module module of the function to create a process from
%% @param Function name of the function to create a process from
%% @param Args arguments to pass to the function to create a process from
%% @param Options additional options.
%% @returns pid of the new process
%% @param Options additional options, see `spawn_option()'. With `monitor'
%% or `{monitor, MonitorOpts}' the new process is also monitored, see
%% `monitor/3' for the monitor options.
%% @returns pid of the new process, or `{Pid, MonitorRef}' when monitoring
%% @doc Create a new process by calling exported Function from Module with Args.
%% @end
%%-----------------------------------------------------------------------------
Expand Down Expand Up @@ -1277,10 +1289,11 @@ make_ref() ->
erlang:nif_error(undefined).

%%-----------------------------------------------------------------------------
%% @param Pid process to send the message to
%% @param Target process, registered name or alias to send the message to
%% @param Message message to send
%% @returns the sent message
%% @doc Send a message to a given process
%% @doc Send a message to a given process. A message sent to a reference
%% that is not an active alias is silently dropped.
%% @end
%%-----------------------------------------------------------------------------
-spec send(Target :: send_destination(), Message :: Message) -> Message.
Expand All @@ -1306,6 +1319,32 @@ send(_Target, _Message) ->
monitor(_Type, _PidOrPort) ->
erlang:nif_error(undefined).

%%-----------------------------------------------------------------------------
%% @param Type type of monitor to create
%% @param PidOrPort pid or port of the object to monitor
%% @param Options monitor options
%% @returns a monitor reference
%% @doc Creates a monitor and allows passing additional options.
%% Currently, only the `{alias, AliasMode}' option is supported. Passing it
%% makes the monitor also an alias on the calling process (see `alias/0').
%% `AliasMode' defines the behaviour of the alias:
%% - explicit_unalias - the alias can be only removed with `unalias/1',
%% - demonitor - the alias is also removed when the monitor is removed,
%% by `demonitor/1' or by the delivery of a `DOWN' message,
%% - reply_demonitor - additionally, the alias is deactivated and the
%% monitor removed (as by `demonitor/1') when the
%% first message sent via the alias is delivered.
%%
%% <b>Note:</b> Unlike Erlang/OTP, the `{tag, Term}' option is not
%% supported and raises `unsupported'.
%% @end
%%-----------------------------------------------------------------------------
-spec monitor
(Type :: process, Pid :: pid() | atom(), [monitor_option()]) -> reference();
(Type :: port, Port :: port() | atom(), [monitor_option()]) -> reference().
monitor(_Type, _PidOrPort, _Options) ->
erlang:nif_error(undefined).

%%-----------------------------------------------------------------------------
%% @param Monitor reference of monitor to remove
%% @returns `true'
Expand Down Expand Up @@ -2147,3 +2186,41 @@ tuple_size(_Tuple) ->
-spec tuple_to_list(Tuple :: tuple()) -> [term()].
tuple_to_list(_Tuple) ->
erlang:nif_error(undefined).

%%-----------------------------------------------------------------------------
%% @returns A reference aliasing the calling process.
%% @doc Creates an alias for the calling process. The alias can be used
%% to send messages to the process like the PID. The alias can also be
%% created along with a monitor - see `monitor/3'. The alias can be
%% removed by calling `unalias/1'.
%% @end
%%-----------------------------------------------------------------------------
-spec alias() -> Alias when Alias :: reference().
alias() ->
erlang:nif_error(undefined).

%%-----------------------------------------------------------------------------
%% @param Options alias options
%% @returns A reference aliasing the calling process.
%% @doc Creates an alias for the calling process, like `alias/0'.
%% With `explicit_unalias' (the default, so `alias([])' is `alias/0')
%% the alias stays active until `unalias/1'; with `reply' it is
%% deactivated when the first message sent via the alias is delivered.
%%
%% <b>Note:</b> Unlike Erlang/OTP, the `priority' option (OTP 28) is
%% not supported and raises `unsupported'.
%% @end
%%-----------------------------------------------------------------------------
-spec alias(Options) -> Alias when Options :: [explicit_unalias | reply], Alias :: reference().
alias(_Options) ->
erlang:nif_error(undefined).

%%-----------------------------------------------------------------------------
%% @param Alias the alias to be removed.
%% @returns `true' if alias was removed, `false' if it was not found
%% @doc Removes process alias. See `alias/0' for more information.
%% @end
%%-----------------------------------------------------------------------------
-spec unalias(Alias) -> boolean() when Alias :: reference().
unalias(_Alias) ->
erlang:nif_error(undefined).
Loading
Loading