Ticket #595: handle_null_exceptions.patch
File handle_null_exceptions.patch, 2.0 KB (added by whiteknight, 13 years ago) |
---|
-
src/exceptions.c
37 37 __attribute__nonnull__(1) 38 38 __attribute__nonnull__(3); 39 39 40 PARROT_DOES_NOT_RETURN 41 static void die_from_null_exception(PARROT_INTERP) 42 __attribute__nonnull__(1); 43 40 44 PARROT_CAN_RETURN_NULL 41 45 static opcode_t * pass_exception_args(PARROT_INTERP, 42 46 ARGIN(const char *sig), … … 51 55 #define ASSERT_ARGS_build_exception_from_args __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 52 56 PARROT_ASSERT_ARG(interp) \ 53 57 || PARROT_ASSERT_ARG(format) 58 #define ASSERT_ARGS_die_from_null_exception __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 59 PARROT_ASSERT_ARG(interp) 54 60 #define ASSERT_ARGS_pass_exception_args __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 55 61 PARROT_ASSERT_ARG(interp) \ 56 62 || PARROT_ASSERT_ARG(sig) \ … … 201 207 { 202 208 ASSERT_ARGS(Parrot_ex_throw_from_op) 203 209 opcode_t *address; 210 if(PMC_IS_NULL(exception) || exception->vtable->base_type != enum_class_Exception) 211 die_from_null_exception(interp); 204 212 PMC * const handler = Parrot_cx_find_handler_local(interp, exception); 205 213 if (PMC_IS_NULL(handler)) { 206 214 STRING * const message = VTABLE_get_string(interp, exception); … … 461 469 { 462 470 ASSERT_ARGS(Parrot_ex_rethrow_from_op) 463 471 if (exception->vtable->base_type != enum_class_Exception) 464 PANIC(interp, "Illegal rethrow");472 die_from_null_exception(interp); 465 473 466 474 Parrot_ex_mark_unhandled(interp, exception); 467 475 … … 753 761 DUMPCORE(); 754 762 } 755 763 764 /* 756 765 766 =item C<static void die_from_null_exception(PARROT_INTERP)> 767 768 Somebody has tried to throw a null exception. This is a fatal error. Print 769 an error message and exit. 770 771 =cut 772 773 */ 774 775 PARROT_DOES_NOT_RETURN 776 static void 777 die_from_null_exception(PARROT_INTERP) 778 { 779 fprintf(stderr, "FATAL: Attempt to throw a NULL PMC\n"); 780 Parrot_exit(interp, 255); 781 } 782 783 757 784 /* 758 785 759 786 =back