Repository navigation
Description
Environment
| Component | Version |
|---|---|
| OTP | 28 (BEAM emulator 16.1.1) |
| LFE | 2.2.1 (commit 99ea89c) |
| Platform | macOS Darwin 24.6.0, aarch64 |
Minimal Reproduction
# Set up LFE on PATH (adjust to your checkout)
export LFE_DIR=/path/to/lfe
export ERL_LIBS="$LFE_DIR"
export PATH="$LFE_DIR/bin:$PATH"
# This crashes:
lfe -eval '(io:format "hello~n" ()) (halt)'The lfe shell script detects that -eval arguments are present (line 101),
appends -noshell to the erl flags, and adds -user lfe_init -extra ... so
that LFE's own init module handles startup.
The crash output:
=ERROR REPORT====
** State machine user_drv terminating
** When server state = {undefined,undefined}
** Reason for termination = error:{badkey,input}
** Callback modules = [user_drv]
** Callback mode = state_functions
** Stacktrace =
** [{erlang,map_get,
[input,#{initial_shell => noshell}],
[{error_info,#{module => erl_erts_errors}}]},
{user_drv,init,1,[{file,"user_drv.erl"},{line,187}]},
...
Interactive lfe (no -eval) works — only the scripting/eval path crashes.
Diagnostic
The call chain
-
bin/lfe(shell script, line 101-103): When arguments remain after flag
processing, appends-noshellto theerlinvocation. -
bin/lfe(line 105): Always appends-user lfe_init -extra ..., making
lfe_init:start/0the user-process entry point. -
lfe_init:start/0(lfe_init.erl:56-73): Callscollect_args/1to
split arguments into eval-strings and script-file. When evals or a script are
present, it enters the noshell branch. -
lfe_init.erl:66-68(the crash site):if OTPRelease >= "26" -> user_drv:start(#{initial_shell => noshell});
This passes a map with only the
initial_shellkey. -
user_drv:init/1(user_drv.erl:179-217, OTP 28): Theinitcallback
computesStartShell = maps:get(initial_shell, Args, undefined) =/= noshell
— which isfalsefor the noshell case. This selects thetrue ->branch at
line 198:true -> TTYState = prim_tty:init( #{ input => maps:get(input, Args), output => raw }), ... {ok, init, {Args, #state{ terminal_mode = maps:get(input, Args), ... }}, ...}
maps:get(input, Args)has no default. SinceArgsis
#{initial_shell => noshell}, the call raises{badkey, input}.
Root cause
OTP 28 (via PR #8962) restructured
-noshell mode into two sub-modes — raw (bypass line editing) and cooked
(the old default behaviour). This changed the arguments() type from:
%% OTP 26–27
-type arguments() :: #{ initial_shell => ..., input => boolean() }.to:
%% OTP 28
-type arguments() :: #{ initial_shell => ..., input => cooked | raw | disabled }.In OTP 27, the noshell code path used maps:get(input, Args, true) — a default
of true. In OTP 28, the refactoring dropped that default, making input a
required key in the noshell path, despite the type spec declaring it
optional (Erlang map types use key => value for optional keys).
There are four bare maps:get(input, Args) calls in OTP 28's user_drv.erl
(lines 200, 202, 401, 429), all without defaults, all reachable when
initial_shell => noshell.
OTP version boundary
| OTP | input key |
Default | LFE -eval works? |
|---|---|---|---|
| ≤ 25 | not in type | N/A (used user:start()) |
yes |
| 26–27 | boolean() |
true |
yes |
| 28 | cooked | raw | disabled |
none | no |
Workaround
Until LFE is patched, use erl -noshell with LFE on the code path instead of
lfe -eval:
export LFE_DIR=/path/to/lfe
# Instead of: lfe -eval '(io:format "hello~n" ()) (halt)'
# Use:
erl -noshell -pa "$LFE_DIR/ebin" -eval '
lfe_shell:run_strings(["(io:format \"hello~n\" ()) (halt)"]),
halt().
'
# For compilation:
erl -noshell -pa "$LFE_DIR/ebin" -eval '
lfe_comp:file("mymod.lfe", [verbose, report, {outdir, "."}]),
halt().
'This bypasses lfe_init and user_drv entirely.
Activity
[-]user_drv issue (placeholder)[/-][+]`lfe -eval` Crash on OTP 28: `user_drv` `{badkey, input}`[/+]Bug/517/otp 28 user drv (#518)
Integrate develop into develop-compile (all tests green) (#523)