# New Ticket Created by Andrew Johnson # Please include the string: [perl #56632] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=56632 >
More details — needless to say the location of the segfault is nowhere near the bug, which I haven't pinpointed yet but I'm getting closer. The segfault occurs when trying to sort the array using Patrick's tail-call comparison function because at the time one of the arguments to the COMPARE() function in src/utils.c is not a pointer to a PMC but actually a small integer (0x21) on the 7th comparison. This is turn is because the first do-while loop inside Parrot_quicksort() underflows, so j goes to (unsigned) -1 which indexes outside of the data array. This in turn occurs because with the tail-call comparison function, the values returned from the COMPARE() function to Parrot_quicksort() are not in the range -1..1, but are actually a pointer. That puts the cuprit somewhere inside the routine Parrot_runops_fromc_args_reti() which is what the COMPARE() function is using to evaluate the sub. I would also question the robustness of the Parrot_quicksort() routine to a comparison function that doesn't do what it's supposed to; no matter what it returns, the result should never be to segfault. I'll report that as a separate bug, which I have confirmed independent of this tail-call issue. - Andrew/Songmaster