# New Ticket Created by "Mehmet Yavuz Selim Soyturk"
# Please include the string: [perl #48134]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=48134 >
Next code segfaults because callmethodcc does another method call,
which causes that interp->current_args gets overwritten.
.sub main :main
$P0 = newclass 'Obj'
$P2 = new 'Obj'
$P2.'some_method'(42)
.end
.sub meth :method
.param pmc a
say a
.end
.namespace ['Obj']
.sub find_method :vtable :method
.param string meth_name
say meth_name
.const .Sub meth = 'meth'
.return (meth)
.end
I attached a patch which seems to solve the problem.
--
Mehmet
Index: src/ops/object.ops
===================================================================
--- src/ops/object.ops (revision 23456)
+++ src/ops/object.ops (working copy)
@@ -55,11 +55,17 @@
PMC *method_pmc, *object;
opcode_t *next;
STRING *meth;
+ opcode_t *current_args;
object = $1;
meth = $2;
next = expr NEXT();
+
+ /* find_method can overwrite interp->current_args! */
+ current_args = interp->current_args;
method_pmc = VTABLE_find_method(interp, object, meth);
+ interp->current_args = current_args;
+
if (PMC_IS_NULL(method_pmc)) {
real_exception(interp, next, METH_NOT_FOUND,
"Method '%Ss' not found", meth);
@@ -91,11 +97,17 @@
PMC *method_pmc, *object;
opcode_t *next;
STRING *meth;
+ opcode_t *current_args;
object = $1;
meth = $2;
next = expr NEXT();
+
+ /* find_method can overwrite interp->current_args! */
+ current_args = interp->current_args;
method_pmc = VTABLE_find_method(interp, object, meth);
+ interp->current_args = current_args;
+
if (PMC_IS_NULL(method_pmc)) {
real_exception(interp, next, METH_NOT_FOUND,
"Method '%Ss' not found", meth);