Ticket #154 (closed bug: fixed)
subclassed ExceptionHandlers can't handle exceptions
Description
Trying to use a subclassed ExceptionHandler causes a segfault. From the backtrace it looks like something's getting stuck in an infinite loop:
#1 0xb7b1939a in Parrot_vsprintf_s (interp=0x804f040, pat=0x81502e8, args=0xbf6b3f40 "�_�,\213\b\b�6m�\002") at src/misc.c:69 #2 0xb7b194f3 in Parrot_vsprintf_c (interp=0x804f040, pat=0xb7e25af8 "%s() not implemented in class '%Ss'", args=0xbf6b3f40 "�_�,\213\b\b�6m�\002") at src/misc.c:91 #3 0xb7af32d6 in build_exception_from_args (interp=0x804f040, ex_type=37, format=0xb7e25af8 "%s() not implemented in class '%Ss'", arglist=0xbf6b3f40 "�_�,\213\b\b�6m�\002") at src/exceptions.c:265 #4 0xb7af39bc in Parrot_ex_throw_from_c_args (interp=0x804f040, ret_addr_unused=0x0, exitcode=37, format=0xb7e25af8 "%s() not implemented in class '%Ss'") at src/exceptions.c:401 #5 0xb7c6fbe4 in cant_do_method (interp=0x804f040, pmc=0x80e8588, methname=0xb7e25fc3 "elements") at ./src/pmc/default.pmc:65 #6 0xb7c7115e in Parrot_default_elements (interp=0x804f040, pmc=0x80e8588) at ./src/pmc/default.c:824 #7 0xb7d41c62 in Parrot_ExceptionHandler_nci_can_handle (interp=0x804f040, pmc=0x80c4888) at ./src/pmc/exceptionhandler.pmc:201 #8 0xb7cb6fb2 in Parrot_NCI_invoke (interp=0x804f040, pmc=0x80c4888, next=0x0) at ./src/pmc/nci.pmc:321 #9 0xb7b0a596 in Parrot_PCCINVOKE (interp=0x804f040, pmc=0x80e79a0, method_name=0x807ad20, signature=0xb7e20df7 "P->I") at src/inter_call.c:2709 #10 0xb7b5b1c5 in Parrot_cx_find_handler_local (interp=0x804f040, task=0xb66d36e0) at src/scheduler.c:795 #11 0xb7af36d8 in Parrot_ex_throw_from_c (interp=0x804f040, exception=0xb66d36e0) at src/exceptions.c:299 #12 0xb7af39d1 in Parrot_ex_throw_from_c_args (interp=0x804f040, ret_addr_unused=0x0, exitcode=37, format=0xb7e25af8 "%s() not implemented in class '%Ss'") at src/exceptions.c:404 #13 0xb7c6fbe4 in cant_do_method (interp=0x804f040, pmc=0x80e8588, methname=0xb7e25fc3 "elements") at ./src/pmc/default.pmc:65 #14 0xb7c7115e in Parrot_default_elements (interp=0x804f040, pmc=0x80e8588) at ./src/pmc/default.c:824 <snip> #7524 0xb7af39d1 in Parrot_ex_throw_from_c_args (interp=0x804f040, ret_addr_unused=0x0, exitcode=37, format=0xb7e25af8 "%s() not implemented in class '%Ss'") at src/exceptions.c:404 #7525 0xb7c6fbe4 in cant_do_method (interp=0x804f040, pmc=0x80e8588, methname=0xb7e25fc3 "elements") at ./src/pmc/default.pmc:65 #7526 0xb7c7115e in Parrot_default_elements (interp=0x804f040, pmc=0x80e8588) at ./src/pmc/default.c:824 #7527 0xb7d41c62 in Parrot_ExceptionHandler_nci_can_handle (interp=0x804f040, pmc=0x80c4888) at ./src/pmc/exceptionhandler.pmc:201 #7528 0xb7cb6fb2 in Parrot_NCI_invoke (interp=0x804f040, pmc=0x80c4888, next=0x0) at ./src/pmc/nci.pmc:321 #7529 0xb7b0a596 in Parrot_PCCINVOKE (interp=0x804f040, pmc=0x80e79a0, method_name=0x807ad20, signature=0xb7e20df7 "P->I") at src/inter_call.c:2709 #7530 0xb7b5b1c5 in Parrot_cx_find_handler_local (interp=0x804f040, task=0x80e74c0) at src/scheduler.c:795 #7531 0xb7af36d8 in Parrot_ex_throw_from_c (interp=0x804f040, exception=0x80e74c0) at src/exceptions.c:299 #7532 0xb7af39d1 in Parrot_ex_throw_from_c_args (interp=0x804f040, ret_addr_unused=0x0, exitcode=37, format=0xb7e25af8 "%s() not implemented in class '%Ss'") at src/exceptions.c:404 #7533 0xb7c6fbe4 in cant_do_method (interp=0x804f040, pmc=0x80e8588, methname=0xb7e25fc3 "elements") at ./src/pmc/default.pmc:65 #7534 0xb7c7115e in Parrot_default_elements (interp=0x804f040, pmc=0x80e8588) at ./src/pmc/default.c:824 #7535 0xb7d41c62 in Parrot_ExceptionHandler_nci_can_handle (interp=0x804f040, pmc=0x80c4888) at ./src/pmc/exceptionhandler.pmc:201 #7536 0xb7cb6fb2 in Parrot_NCI_invoke (interp=0x804f040, pmc=0x80c4888, next=0x0) at ./src/pmc/nci.pmc:321 #7537 0xb7b0a596 in Parrot_PCCINVOKE (interp=0x804f040, pmc=0x80e79a0, method_name=0x807ad20, signature=0xb7e20df7 "P->I") at src/inter_call.c:2709 #7538 0xb7b5b1c5 in Parrot_cx_find_handler_local (interp=0x804f040, task=0x80e7628) at src/scheduler.c:795 #7539 0xb7af3a58 in Parrot_ex_throw_from_op (interp=0x804f040, exception=0x80e7628, dest=0x812eb8c) at src/exceptions.c:198 #7540 0xb7abc77c in Parrot_throw_p (cur_opcode=0x812eb84, interp=0x804f040) at src/ops/core.ops:853 #7541 0xb7b5ac80 in runops_slow_core (interp=0x804f040, pc=0x812eb84) at src/runops_cores.c:228 #7542 0xb7b10769 in runops_int (interp=0x804f040, offset=0) at src/interpreter.c:984 #7543 0xb7b11151 in runops (interp=0x804f040, offs=0) at src/inter_run.c:108 #7544 0xb7b11541 in runops_args (interp=0x804f040, sub=0x80e8ba0, obj=0x80bdcf0, meth_unused=0x0, sig=0xb7e1b973 "vP", ap=0xbfeb1f0c "\210\213\016\bX\037�@<���\004\b�\213\016\b\210\213\016\b\b|�X\037뿬\003߷@�\004\b\001") at src/inter_run.c:248 #7545 0xb7b12406 in Parrot_runops_fromc_args (interp=0x804f040, sub=0x80e8ba0, sig=0xb7e1b973 "vP") at src/inter_run.c:315 #7546 0xb7aefd67 in Parrot_runcode (interp=0x804f040, argc=1, argv=0xbfeb2088) at src/embed.c:984 #7547 0xb7df03ac in imcc_run_pbc (interp=0x804f040, obj_file=0, output_file=0x0, argc=1, argv=0xbfeb2088) at compilers/imcc/main.c:824 #7548 0xb7df0fc5 in imcc_run (interp=0x804f040, sourcefile=0xbfeb3347 "subclass_eh_sf.pir", argc=1, argv=0xbfeb2088) at compilers/imcc/main.c:1116 #7549 0x08048988 in main (argc=1, argv=0xbfeb2088) at src/main.c:61
The code to duplicate the behavior is very simple. I just pared down t/pmc/exceptionhandler.t, which already had a note about the bug.
.sub main :main .local pmc myhandler, myeh myhandler = subclass ['ExceptionHandler'], ['MyHandler'] #myhandler = get_class ['ExceptionHandler'] new myeh, myhandler set_addr myeh, subclassed_handler push_eh myeh $P0 = new ['Exception'] throw $P0 subclassed_handler: say "caught an ex" .end
Change History
Note: See
TracTickets for help on using
tickets.