Elixir and Erlang/OTP versions
Erlang/OTP 28 [erts-16.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]
Elixir 1.20.0-rc.4 (116f8f4) (compiled with Erlang/OTP 28)
Operating system
any
Current behavior
Repro in iex:
Code.compile_string("raise \"boom\"")
** (RuntimeError) boom
nofile:1: (file)
(elixir 1.20.0-rc.4) src/elixir_compiler.erl:101: :elixir_compiler.dispatch/4
(elixir 1.20.0-rc.4) src/elixir_compiler.erl:76: :elixir_compiler.compile/4
(elixir 1.20.0-rc.4) src/elixir_compiler.erl:42: :elixir_compiler.optimize_defmodule/2
(elixir 1.20.0-rc.4) src/elixir_lexical.erl:18: :elixir_lexical.run/3
(elixir 1.20.0-rc.4) src/elixir_compiler.erl:21: :elixir_compiler.quoted/3
iex:1: (file)
iex(1)> IO.inspect(:sys.get_state(:elixir_code_server))
{:elixir_code_server, %{}, {[], [], 1}, %{}}
Code.compile_string("raise \"boom\"")
** (RuntimeError) boom
nofile:1: (file)
(elixir 1.20.0-rc.4) src/elixir_compiler.erl:101: :elixir_compiler.dispatch/4
(elixir 1.20.0-rc.4) src/elixir_compiler.erl:76: :elixir_compiler.compile/4
(elixir 1.20.0-rc.4) src/elixir_compiler.erl:42: :elixir_compiler.optimize_defmodule/2
(elixir 1.20.0-rc.4) src/elixir_lexical.erl:18: :elixir_lexical.run/3
(elixir 1.20.0-rc.4) src/elixir_compiler.erl:21: :elixir_compiler.quoted/3
iex:2: (file)
iex(2)> IO.inspect(:sys.get_state(:elixir_code_server))
{:elixir_code_server, %{}, {[], [], 2}, %{}}
:code.all_loaded() |> Enum.filter(& elem(&1, 0) |> to_string |> String.starts_with?("elixir_compiler_"))
[elixir_compiler_1: [], elixir_compiler_0: []]
Code.purge_compiler_modules()
{:ok, 0}
:code.all_loaded() |> Enum.filter(& elem(&1, 0) |> to_string |> String.starts_with?("elixir_compiler_"))
[elixir_compiler_1: [], elixir_compiler_0: []]
Notice the counter gets incremented but modules are not registered in code server state. They stay loaded and is not purgeable by Code.purge_compiler_modules/0
The same happens if the crash is in module body
Code.compile_string("defmodule Foo do\n raise \"boom\"\nend")
Likely reason:
When Module:Fun(Args) in dispatch crashes return_compiler_module is not called
|
dispatch(Module, Fun, Args, Purgeable) -> |
|
Res = Module:Fun(Args), |
|
return_compiler_module(Module, Purgeable), |
|
Res. |
Expected behavior
Two alternatives
- Failed modules should be accounted for in code server state and purgeable
- Should be purged right away
Elixir and Erlang/OTP versions
Erlang/OTP 28 [erts-16.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]
Elixir 1.20.0-rc.4 (116f8f4) (compiled with Erlang/OTP 28)
Operating system
any
Current behavior
Repro in iex:
Notice the counter gets incremented but modules are not registered in code server state. They stay loaded and is not purgeable by
Code.purge_compiler_modules/0The same happens if the crash is in module body
Likely reason:
When
Module:Fun(Args)indispatchcrashesreturn_compiler_moduleis not calledelixir/lib/elixir/src/elixir_compiler.erl
Lines 100 to 103 in a37db60
Expected behavior
Two alternatives