# New Ticket Created by  Andrew Johnson 
# Please include the string:  [perl #56636]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=56636 >


If sort is given a comparison function that always returns >0, the result is
a segfault.

    .sub 'main' :main
        .local pmc array
        array = new 'ResizablePMCArray'
        push array, 4
        push array, 5
        push array, 3
        push array, 2
        push array, 5
        push array, 1

        $S0 = join ' ', array
        say $S0

        $P0 = get_global 'cmp_func'
        array.sort($P0)
        $S0 = join ' ', array
        say $S0
    .end

    .sub 'cmp_func'
        .param pmc a
        .param pmc b
        $I0 = 1
        .return ($I0)
    .end


Parrot_quicksort() is in src/utils.c; the first do-while loop has nothing to
stop it when j reaches 0, so it keeps going outside of the data array. I
guess that the while condition needs j > 0 adding to it to prevent that from
happening.

- Andrew/Songmaster

Reply via email to