As far as I understand, the BEAM keeps last exception information saved into the process structure:
struct process {
[...]
Uint freason; /* Reason for detected failure. */
Eterm fvalue; /* Exit & Throw value (failure reason) */
[...]
Eterm ftrace; /* Latest exception stack trace dump */
[...]
}
As I understand, there are some specific opcodes that allow to copy these internal fields to regular registers (x[0], x[1], x[2]).
Those opcodes are try_case, catch_end and stacktrace_build (this later write only to x[0]).
- Did I understand correctly how the BEAM works?
- Did I forgot any other opcode that writes exception information to regular x registers?
fvalue and ftrace are terms, so GC must treat them as live roots, therefore they may use some space in the process heap.
I assume they are not kept forever and at a certain point they are cleared up.
- Which events or opcodes trigger a cleanup?
- Are they cleaned up all at the same time?
So my assumpion is that after one of those cleanups raw_raise cannot work.
So my question can be also rephrased to: after which opcode it is not possible anymore to have raw_raise?