Ticket #1078: never_ending_exception.patch
File never_ending_exception.patch, 2.3 KB (added by NotFound, 12 years ago) |
---|
-
src/pmc/exceptionhandler.pmc
22 22 23 23 #include "parrot/oplib/ops.h" 24 24 25 /* Arbitrarily choosen value */ 26 #define HANDLING_COUNTER_LIMIT 512 27 25 28 pmclass ExceptionHandler extends Continuation auto_attrs { 26 29 27 30 ATTR PMC *handled_types; 28 31 ATTR PMC *handled_types_except; 29 32 ATTR INTVAL min_severity; 30 33 ATTR INTVAL max_severity; 34 ATTR INTVAL handling_counter; 31 35 32 36 /* 33 37 … … 120 124 121 125 VTABLE opcode_t *invoke(void *next) { 122 126 opcode_t * const pc = PARROT_CONTINUATION(SELF)->address; 127 INTVAL counter; 128 GET_ATTR_handling_counter(INTERP, SELF, counter); 129 ++counter; 130 SET_ATTR_handling_counter(INTERP, SELF, counter); 123 131 124 132 Parrot_continuation_check(interp, SELF); 125 133 Parrot_continuation_rewind_environment(interp, SELF); … … 158 166 STRING * const sev = CONST_STRING(interp, "severity"); 159 167 STRING * const ex_str = CONST_STRING(interp, "Exception"); 160 168 161 INTVAL severity = VTABLE_get_integer_keyed_str(interp, exception, sev); 169 const INTVAL severity = VTABLE_get_integer_keyed_str(interp, exception, sev); 170 const INTVAL type = VTABLE_get_integer_keyed_str(interp, exception, CONST_STRING(interp, "type")); 162 171 172 /* Declare that it can't handle any exception after reaching the limit, 173 * giving opportunity to other handler to take control. 174 * Avoid control exceptions, that are supposed to be less error prone 175 * and might need longer usages. */ 176 INTVAL counter; 177 GET_ATTR_handling_counter(INTERP, SELF, counter); 178 if (type < CONTROL_RETURN && counter >= HANDLING_COUNTER_LIMIT) 179 RETURN(INTVAL 0); 180 163 181 if (exception->vtable->base_type == enum_class_Exception 164 182 || VTABLE_isa(INTERP, exception, ex_str)) { 165 183 PMC *handled_types; … … 178 196 } 179 197 if (! PMC_IS_NULL(handled_types)) { 180 198 const INTVAL elems = VTABLE_elements(interp, handled_types); 181 const INTVAL type = VTABLE_get_integer_keyed_str(interp, exception, CONST_STRING(interp, "type"));182 199 INTVAL i; 183 200 184 201 for (i = 0; i < elems; i++) {