Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit d522e4f

Browse files
ibuclawwilzbach
authored andcommitted
rt.dwarfeh: Free current inflight exception before calling _d_print_throwable()
As _d_print_throwable() itself may throw multiple times when calling core.demangle, and with the uncaught exception still on the EH stack, this doesn't bode well with core.demangle's error recovery.
1 parent 3574f0a commit d522e4f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/rt/dwarfeh.d

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ extern(C) void _d_throwdwarf(Throwable o)
229229
* try/catch.
230230
*/
231231
fprintf(stderr, "uncaught exception\n");
232+
/**
233+
As _d_print_throwable() itself may throw multiple times when calling core.demangle,
234+
and with the uncaught exception still on the EH stack, this doesn't bode well with core.demangle's error recovery.
235+
*/
236+
__dmd_begin_catch(&eh.exception_object);
232237
_d_print_throwable(o);
233238
abort();
234239
assert(0);

test/exceptions/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,14 @@ $(ROOT)/unknown_gc.done: STDERR_EXP="'unknowngc'"
4646
$(ROOT)/static_dtor.done: STDERR_EXP="dtor_called_more_than_once"
4747
$(ROOT)/future_message.done: STDERR_EXP="exception I have a custom message. exception exception "
4848
$(ROOT)/static_dtor.done: NEGATE=!
49-
$(ROOT)/rt_trap_exceptions.done: STDERR_EXP="uncaught exception\nobject.Exception@rt_trap_exceptions.d(11): exception"
50-
$(ROOT)/rt_trap_exceptions.done: NEGATE=!
49+
$(ROOT)/rt_trap_exceptions.done: STDERR_EXP="object.Exception@src/rt_trap_exceptions.d(12): this will abort"
50+
$(ROOT)/rt_trap_exceptions.done: STDERR_EXP2="src/rt_trap_exceptions.d:8 main"
5151
$(ROOT)/%.done: $(ROOT)/%
5252
@echo Testing $*
5353
$(NEGATE) $(QUIET)$(TIMELIMIT)$(ROOT)/$* $(RUN_ARGS) 2>&1 1>/dev/null | grep -qF $(STDERR_EXP)
54+
if [ ! -z "$(STDERR_EXP2)" ] ; then \
55+
$(NEGATE) $(QUIET)$(TIMELIMIT)$(ROOT)/$* $(RUN_ARGS) 2>&1 1>/dev/null | grep -qF $(STDERR_EXP2); \
56+
fi
5457
@touch $@
5558

5659
$(ROOT)/unittest_assert: DFLAGS+=-unittest

0 commit comments

Comments
 (0)