Skip to content

Release boot halts, if :io is used inon_load #14960

@robertfiko

Description

@robertfiko

Elixir and Erlang/OTP versions

Erlang/OTP 28 [erts-16.1.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit]

Elixir 1.19.3 (compiled with Erlang/OTP 28)

Operating system

Mac OS 26.1 (but probably others as well)

Current behavior

The issue came out in a corporate software, but I could reproduce it on a small example.
I've just genersted a new Elixir app with mix (mix new loader --app loader) and added the following small Erlang file to the src folder and of course added that folder to the erlc_paths

-module(loader_erl).
-on_load(init/0).

init() ->
    io:format("Loader Erlang module loaded successfully.~n"),
    ok.

The iex -S mix command works just fine (though no io is visible), but if I make a release with mix release (can be dev and prod as well), and I would like to start from the release it halts.

In the bash file I've modified a bit, that loading script, I've added this: -init_debug

start () {
  export_release_sys_config
  REL_EXEC="$1"
  shift
  exec "$REL_VSN_DIR/$REL_EXEC" \
       --cookie "$RELEASE_COOKIE" \
       $(release_distribution "$RELEASE_NODE") \
       --erl "-mode $RELEASE_MODE -init_debug" \
       --erl-config "$RELEASE_SYS_CONFIG" \
       --boot "$REL_VSN_DIR/$RELEASE_BOOT_SCRIPT" \
       --boot-var RELEASE_LIB "$RELEASE_ROOT/lib" \
       --vm-args "$RELEASE_VM_ARGS" "$@"
}

So I could see where it holds.

...
old,500},{discard_threshold_periodic_check,30000},{metadata,[]}]},{maxT,infinity},{maxP,infinity},{mod,{'Elixir.Logger.App',[]}}]}]}}
{done_in_microseconds,10}
{apply,{application,load,[{application,loader,[{description,"loader"},{vsn,"0.1.0"},{id,[]},{modules,['Elixir.Loader',loader_erl]},{registered,[]},{applications,[kernel,stdlib,elixir,logger]},{optional_applications,[]},{included_applications,[]},{env,[]},{maxT,infinity},{maxP,infinity}]}]}}
{done_in_microseconds,3}
{progress,applications_loaded}
{apply,{application,start_boot,[kernel,permanent]}}
{running_on_load_handler,loader_erl}

The similar behaviour works with rebar3.

Source code: loader.zip

Expected behavior

The release should start

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions