# New Ticket Created by chromatic # Please include the string: [perl #42229] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42229 >
$ parrot t/pmc/exporter_6.pir ok 1 - import() with no args does nothing Segmentation fault (core dumped) $ gdb parrot GNU gdb 6.4.90-debian Copyright (C) 2006 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i486-linux-gnu"...Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1". (gdb) run t/pmc/exporter_6.pir Starting program: /home/chromatic/dev/parrot/parrot t/pmc/exporter_6.pir [Thread debugging using libthread_db enabled] [New Thread -1212327744 (LWP 29565)] [New Thread -1212466272 (LWP 29568)] [New Thread -1220858976 (LWP 29569)] ok 1 - import() with no args does nothing Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1212327744 (LWP 29565)] 0xb7dadb1a in Parrot_free_context (interp=0x8051008, ctxp=0x0, re_use=1) at src/gc/register.c:411 411 slot = ctxp->regs_mem_size >> 3; (gdb) bt #0 0xb7dadb1a in Parrot_free_context (interp=0x8051008, ctxp=0x0, re_use=1) at src/gc/register.c:411 #1 0xb7e6f1c2 in Parrot_RetContinuation_invoke (interp=0x8051008, pmc=0x820de88, next=0x0) at src/pmc/retcontinuation.pmc:91 #2 0xb7cbbf1f in Parrot_returncc (cur_opcode=0x8244bcc, interp=0x8051008) at src/ops/core.ops:456 #3 0xb7dbc9bb in runops_slow_core (interp=0x8051008, pc=0x8244bcc) at src/runops_cores.c:184 #4 0xb7da72fe in runops_int (interp=0x8051008, offset=0) at src/interpreter.c:775 #5 0xb7daca7e in runops (interp=0x8051008, offs=0) at src/inter_run.c:88 #6 0xb7dacd0d in runops_args (interp=0x8051008, sub=0x820df3c, obj=0x8096b90, meth=0x0, sig=0xb7f21636 "vP", ap=0xbfcb033c "([EMAIL PROTECTED]") at src/inter_run.c:202 #7 0xb7dace28 in Parrot_runops_fromc_args (interp=0x8051008, sub=0x820df3c, sig=0xb7f21636 "vP") at src/inter_run.c:304 #8 0xb7e0a8de in Parrot_runcode (interp=0x8051008, argc=1, argv=0xbfcb04b8) at src/embed.c:805 #9 0x0804ae80 in main (argc=1, argv=0xbfcb04b8) at compilers/imcc/main.c:732 Invoking a RetContinuation requires freeing the current context (or at least decreasing its reference count). The problem is that the PCCMETHOD code doesn't set the current context in the RetContinuation PMC. Note that setting the current context is awfully ugly. The attached patch fixes the problem for me, but I'm not sure it's completely correct. src/sub.c:174 says: cc->from_ctx = NULL; /* filled in during a call */ I can't track down where that actually happens. Still, the current patch identifies the problem and makes the test pass without breaking anything else. -- c
=== lib/Parrot/Pmc2c/PCCMETHOD.pm ================================================================== --- lib/Parrot/Pmc2c/PCCMETHOD.pm (revision 2659) +++ lib/Parrot/Pmc2c/PCCMETHOD.pm (local) @@ -379,7 +379,8 @@ parrot_context_t *ctx = Parrot_push_context(interp, n_regs_used); PMC* ccont = caller_ctx->current_cont; - ctx->current_cont = ret_cont; + ctx->current_cont = ret_cont; + PMC_cont(ret_cont)->from_ctx = caller_ctx; current_args = interp->current_args; interp->current_args = NULL;