Ticket #218 (assigned bug) — at Version 7

Opened 13 years ago

Last modified 11 years ago

can't sort a PIR subclass of an RPA.

Reported by: coke Owned by: whiteknight
Priority: normal Milestone:
Component: core Version:
Severity: high Keywords: tcl blocker
Cc: Language:
Patch status: Platform: all

Description (last modified by bacek) (diff)

This patch solves the ticket. But I'm not sure how "kosher" is it.

diff --git a/src/pmc/fixedpmcarray.pmc b/src/pmc/fixedpmcarray.pmc
index 6eb6e9f..4146ca4 100644
--- a/src/pmc/fixedpmcarray.pmc
+++ b/src/pmc/fixedpmcarray.pmc
@@ -47,7 +47,7 @@ Sort this array, optionally using the provided cmp_func
         const INTVAL n = SELF.elements();
 
         if (n > 1)
-           Parrot_quicksort(interp, (void **)PMC_array(SELF), n, cmp_func);
+           Parrot_quicksort(interp, (void **)SELF.get_pointer(), n, cmp_func);
     }
 
 /*
@@ -144,6 +144,19 @@ fixed sized array).
 
 /*
 
+=item C<void *get_pointer()>
+
+Get pointer to stored data. Used in sort method.
+
+=cut
+
+*/
+
+    VTABLE void * get_pointer() {
+        return PMC_array(SELF);
+    }
+/*
+
 =item C<INTVAL get_integer()>
 
 Returns the number of elements in the array.

Change History

Changed 13 years ago by pmichaud

This is a duplicate of RT #54520 -- so look there for further examples.

Pm

Changed 13 years ago by whiteknight

  • status changed from new to assigned
  • owner set to whiteknight
  • component changed from none to core
  • platform set to all
  • milestone set to 1.0

Changed 13 years ago by whiteknight

I'm looking at the RT ticket which seems to indicate that this is a problem with class instantiation. I'm looking at the relevant code in src/pmc/class.pmc and src/pmc/object.pmc, but don't see any obvious errors that would prevent methods from being properly inherited by subclasses. I'm going to run some tests today, and when I get home tonight I'll run it through GDB to try and figure out where the problem lies.

Changed 13 years ago by whiteknight

This isn't exactly a duplicate of RT #54520. That ticket involves changing the MRO of a class that's already been instantiated. That is not the case in this ticket where the MRO is not being modified at all after instantiating the ResizablePMCArray and the RPA classes.

On cursory inspection, the relevant code in object.pmc and class.pmc looks to be doing The Right Thing. I'll try to look at this issue later tonight in the debugger to see what's going on here.

Changed 13 years ago by whiteknight

As a quick note, as of r38214 on Ubuntu 9.04 x86_64 the test code above causes a segfault/coredump instead of printing out the error message. This is obviously a change from how it was failing, and it's a change in the wrong direction.

Changed 13 years ago by whiteknight

In r38217 I made a small change to the sort method. Previously, it was using the macro PMC_size() to determine the number of elements in the array, which only worked with FixedPMCArray PMCs, and not subclasses. So I changed that to a call to VTABLE_elements, which solves that one problem.

Of course, that didn't solve the ticket entirely (or I would have closed it). It gets past the part where it was failing previously, and now segfaults somewhere in the call to the comparison PIR function. I don't have time to dig into it tonight. Here's the backtrace in case anybody wants to play with it:

Program received signal SIGSEGV, Segmentation fault.
0x00007f1f053c5382 in Parrot_convert_arg (interp=0x6fd080, st=0x7fff0db07860)
    at src/call/pcc.c:1126
1126	            UVal_str(st->val) = VTABLE_get_string(interp, UVal_pmc(st->val));
(gdb) bt
#0  0x00007f1f053c5382 in Parrot_convert_arg (interp=0x6fd080, 
    st=0x7fff0db07860) at src/call/pcc.c:1126
#1  0x00007f1f053c5ad2 in Parrot_process_args (interp=0x6fd080, 
    st=0x7fff0db07860, param_or_result=<value optimized out>)
    at src/call/pcc.c:1705
#2  0x00007f1f053c6942 in parrot_pass_args_fromc (interp=0x6fd080, 
    sig=0x7f1f0556b42c "PP", dest=0x85fef8, old_ctxp=0x85bee0, 
    ap=0x7fff0db07a00) at src/call/pcc.c:1927
#3  0x00007f1f053c9c39 in runops_args (interp=0x6fd080, sub=0x7f9480, 
    obj=0x7862c0, meth_unused=<value optimized out>, sig=0x7f1f0556b42b "IPP", 
    ap=0x7fff0db07a00) at src/call/ops.c:241
#4  0x00007f1f053ca377 in Parrot_runops_fromc_args_reti (interp=0x6fd080, 
    sub=0x0, sig=0x7f1f0556b42b "IPP") at src/call/ops.c:403
#5  0x00007f1f0541386e in Parrot_quicksort (interp=0x6fd080, data=0x7f6db0, 
    n=2, cmp=0x7f9480) at src/utils.c:941
#6  0x00007f1f054ede2f in Parrot_FixedPMCArray_nci_sort (interp=0x6fd080, 
    pmc=<value optimized out>) at ./src/pmc/fixedpmcarray.pmc:50
#7  0x00007f1f054991a2 in Parrot_NCI_invoke (interp=0x6fd080, pmc=0x0, 
    next=0x85feb0) at ./src/pmc/nci.pmc:329
#8  0x00007f1f0540bafd in runops_slow_core (interp=0x6fd080, pc=0x85fe98)
    at src/runops_cores.c:461
#9  0x00007f1f053c8ef2 in runops_int (interp=0x6fd080, offset=0)
    at src/interpreter.c:982
#10 0x00007f1f053c9a5b in runops (interp=0x6fd080, offs=<value optimized out>)
    at src/call/ops.c:107
#11 0x00007f1f053c9bd0 in runops_args (interp=0x6fd080, sub=0x7f94e0, 
    obj=<value optimized out>, meth_unused=<value optimized out>, 
    sig=0x7f1f0555d9c5 "vP", ap=0x7fff0db07cf0) at src/call/ops.c:255
#12 0x00007f1f053ca5c7 in Parrot_runops_fromc_args (interp=0x6fd080, sub=0x0, 
    sig=0x7f1f0555d9c5 "vP") at src/call/ops.c:324
#13 0x00007f1f0554c7a3 in imcc_run (interp=0x6fd080, 
    sourcefile=0x7fff0db086e1 "subclasstest.pir", argc=1, argv=0x7fff0db07f40)
    at compilers/imcc/main.c:806
#14 0x0000000000400bb2 in main (argc=1, argv=0x7fff0db07f40) at src/main.c:61

Changed 13 years ago by bacek

  • description modified (diff)
Note: See TracTickets for help on using tickets.