Index: src/exceptions.c =================================================================== --- src/exceptions.c (revision 38496) +++ src/exceptions.c (working copy) @@ -37,6 +37,10 @@ __attribute__nonnull__(1) __attribute__nonnull__(3); +PARROT_DOES_NOT_RETURN +static void die_from_null_exception(PARROT_INTERP) + __attribute__nonnull__(1); + PARROT_CAN_RETURN_NULL static opcode_t * pass_exception_args(PARROT_INTERP, ARGIN(const char *sig), @@ -51,6 +55,8 @@ #define ASSERT_ARGS_build_exception_from_args __attribute__unused__ int _ASSERT_ARGS_CHECK = \ PARROT_ASSERT_ARG(interp) \ || PARROT_ASSERT_ARG(format) +#define ASSERT_ARGS_die_from_null_exception __attribute__unused__ int _ASSERT_ARGS_CHECK = \ + PARROT_ASSERT_ARG(interp) #define ASSERT_ARGS_pass_exception_args __attribute__unused__ int _ASSERT_ARGS_CHECK = \ PARROT_ASSERT_ARG(interp) \ || PARROT_ASSERT_ARG(sig) \ @@ -201,6 +207,8 @@ { ASSERT_ARGS(Parrot_ex_throw_from_op) opcode_t *address; + if(PMC_IS_NULL(exception) || exception->vtable->base_type != enum_class_Exception) + die_from_null_exception(interp); PMC * const handler = Parrot_cx_find_handler_local(interp, exception); if (PMC_IS_NULL(handler)) { STRING * const message = VTABLE_get_string(interp, exception); @@ -461,7 +469,7 @@ { ASSERT_ARGS(Parrot_ex_rethrow_from_op) if (exception->vtable->base_type != enum_class_Exception) - PANIC(interp, "Illegal rethrow"); + die_from_null_exception(interp); Parrot_ex_mark_unhandled(interp, exception); @@ -753,7 +761,26 @@ DUMPCORE(); } +/* +=item C + +Somebody has tried to throw a null exception. This is a fatal error. Print +an error message and exit. + +=cut + +*/ + +PARROT_DOES_NOT_RETURN +static void +die_from_null_exception(PARROT_INTERP) +{ + fprintf(stderr, "FATAL: Attempt to throw a NULL PMC\n"); + Parrot_exit(interp, 255); +} + + /* =back