Skip to content

Commit 1961db0

Browse files
committed
don't crash when :int.ni throws
1 parent f5f62da commit 1961db0

File tree

1 file changed

+24
-8
lines changed
  • apps/elixir_ls_debugger/lib/debugger

1 file changed

+24
-8
lines changed

apps/elixir_ls_debugger/lib/debugger/server.ex

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,15 +2187,31 @@ defmodule ElixirLS.Debugger.Server do
21872187
Output.debugger_console("Interpreting module #{inspect(module)}")
21882188
end
21892189

2190-
case :int.ni(module) do
2191-
:error ->
2192-
{:error, :cannot_interpret}
2190+
try do
2191+
case :int.ni(module) do
2192+
:error ->
2193+
{:error, :cannot_interpret}
2194+
2195+
{:module, _} ->
2196+
# calling module_info when paused on a breakpoint can deadlock the debugger
2197+
# cache it for each interpreted module
2198+
ModuleInfoCache.store(module)
2199+
:ok
2200+
end
2201+
catch
2202+
kind, error ->
2203+
# :int.ni can raise
2204+
# ** (MatchError) no match of right hand side value: {:error, :on_load_failure}
2205+
# (debugger 5.3) int.erl:531: anonymous fn_3 in :int.load_2
2206+
# (debugger 5.3) int.erl:527: :int.load_2
2207+
{payload, stacktrace} = Exception.blame(kind, error, __STACKTRACE__)
2208+
message = Exception.format(kind, payload, stacktrace)
21932209

2194-
{:module, _} ->
2195-
# calling module_info when paused on a breakpoint can deadlock the debugger
2196-
# cache it for each interpreted module
2197-
ModuleInfoCache.store(module)
2198-
:ok
2210+
Output.debugger_console(
2211+
"Error during interpreting module #{inspect(module)}: #{message}"
2212+
)
2213+
2214+
{:error, :cannot_interpret}
21992215
end
22002216
end
22012217
else

0 commit comments

Comments
 (0)