legoscia

legoscia

No crash reports in default Logger configuration

I just spent some time chasing down a bug that would have been easier to find if I had seen a certain crash report - but it seems like crash reports are not being shown in Elixir by default?

For example, when a process started with proc_lib:spawn crashes in Erlang, a crash report is printed:

$ erl
Erlang/OTP 21 [erts-10.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Eshell V10.0  (abort with ^G)
1> proc_lib:spawn(fun() -> error(pang) end).
<0.78.0>
2> =CRASH REPORT==== 14-May-2019::10:00:59.621479 ===
  crasher:
    initial call: erl_eval:'-expr/5-fun-3-'/0
    pid: <0.78.0>
    registered_name: []
    exception error: pang
      in function  shell:apply_fun/3 (shell.erl, line 907)
    ancestors: [<0.76.0>]
    message_queue_len: 0
    messages: []
    links: []
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 376
    stack_size: 27
    reductions: 207
  neighbours:

But not when doing the same thing in Elixir:

$ iex
Erlang/OTP 21 [erts-10.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Interactive Elixir (1.7.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :proc_lib.spawn(fn -> :erlang.error(:pang) end)
#PID<0.103.0>

(it’s better to use a plain spawn than proc_lib:spawn in code like this, but this is an easy way to provoke a crash report - and this is how the code I was debugging was written. With a plain spawn, we get an error report instead of a crash report, and it’s displayed clearly in both Erlang and Elixir.)

My questions:

  • Why does this happen?
  • Is this a bug or a feature? It seems to me like dropping error messages like this is incorrect, but perhaps I’m missing something.
  • Should I change my Logger configuration somehow?

Most Liked

dom

dom

Have you been able to find an answer? Enabling :handle_sasl_reports in Logger config helps, but my understanding on OTP-21+ is that error reports go directly to the logger without involving SASL, so I don’t get why the flag would be needed.

It’s a problem in dev because I need to choose between enabling the flag, which adds a ton of log spam due to SASL progress reports, or not enabling it, in which case processes die completely silently…

Edit: Perhaps it’s because Elixir calls the old :error_logger:

https://github.com/elixir-lang/elixir/blob/1fa111de78036fbc2ec0300d8444313e5dd3d060/lib/elixir/lib/dynamic_supervisor.ex#L990

So the error reports go through SASL, unlike the Erlang ones, which use the new logger directly:

https://github.com/erlang/otp/blob/master/lib/stdlib/src/supervisor.erl#L40

hauleth

hauleth

You still could use:

config :logger, :console,
  format: "[$level] $message\n"

As config will be automatically merged for 1 level.

as of erlang 21 handle_otp_reports must be set although true is the default

This is not true, you need only :handle_sasl_reports as handle_otp_reports: true is default (trust me, I have written Logger for Elixir 1.10+). The only thing is that :handle_sasl_reports will be ignored if :handle_otp_reports is false (which with current implementation is quite problematic, and IMHO setting handle_otp_reports: false should be deprecated).

hauleth

hauleth

Which version of Elixir do you use? Maybe I will be able to pinpoint the problem.

Where Next?

Popular in Questions Top

_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41989 114
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement