Skip to content

Commit 256c096

Browse files
FKubisSWMmat-hek
authored andcommitted
Fixed reraise not caught issue
Signed-off-by: Mateusz Front <[email protected]>
1 parent d7581ac commit 256c096

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/libAtomVM/opcodesswitch.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,10 @@ static bool sort_kv_pairs(struct kv_pair *kv, int size, GlobalContext *global)
14151415
return true;
14161416
}
14171417

1418+
static bool is_exception_class(term t) {
1419+
return t == ERROR_ATOM || t == LOWERCASE_EXIT_ATOM || t == THROW_ATOM;
1420+
}
1421+
14181422
static term maybe_alloc_boxed_integer_fragment(Context *ctx, avm_int64_t value)
14191423
{
14201424
#if BOXED_TERMS_REQUIRED_FOR_INT64 > 1
@@ -3746,6 +3750,12 @@ HOT_FUNC int scheduler_entry_point(GlobalContext *glb)
37463750
#ifdef IMPL_EXECUTE_LOOP
37473751
TRACE("raise/2 stacktrace=0x%lx exc_value=0x%lx\n", stacktrace, exc_value);
37483752
if (stacktrace_is_built(stacktrace)) {
3753+
// FIXME: This is a temporary solution as in some niche cases of reraise the x_regs[0] is
3754+
// overwritten and it does not represent exception class
3755+
if (!is_exception_class(x_regs[0])) {
3756+
x_regs[0] = ERROR_ATOM;
3757+
}
3758+
x_regs[1] = exc_value;
37493759
x_regs[2] = stacktrace;
37503760
} else {
37513761
x_regs[0] = stacktrace_exception_class(stacktrace);

0 commit comments

Comments
 (0)