Ticket #1826 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

custom cmp kills FixedIntegerArray::sort

Reported by: cotto Owned by:
Priority: normal Milestone:
Component: none Version: 2.8.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description

Passing a custom comparison sub to FixedIntegerArray's sort method causes a segfault in code that works as expected with FixedPMCArray. The only difference between the two scripts below is the type of $P0.

cotto@feather:/usr/src/parrot/parrot-svn-committable\ 1 $ cat inner.pir
.sub main :main
    $P0 = new ['FixedPMCArray']
    $P0 = 3
    $P0[0] = 1
    $P0[1] = 3
    $P0[2] = 3
    $P1 = get_global 'sorter'
    $P0.'sort'($P1)
.end

.sub sorter
    .param pmc a
    .param pmc b
    say "sort"

    .return (a)
.end


cotto@feather:/usr/src/parrot/parrot-svn-committable\ 1 $ ./parrot inner.pir
sort
sort
sort
cotto@feather:/usr/src/parrot/parrot-svn-committable\ 1 $ cat inner.pir 
.sub main :main
    $P0 = new ['FixedIntegerArray']
    $P0 = 3
    $P0[0] = 1
    $P0[1] = 3
    $P0[2] = 3
    $P1 = get_global 'sorter'
    $P0.'sort'($P1)
.end

.sub sorter
    .param pmc a
    .param pmc b
    say "sort"

    .return (a)
.end
 

cotto@feather:/usr/src/parrot/parrot-svn-committable\ 1 $ ./parrot inner.pir 
Segmentation fault

Change History

Changed 4 years ago by Vasily Chekalkin

  • status changed from new to closed
  • resolution set to fixed

Pass cmp signature to quicksort to avoid segmentation fault during fetching wrong type of arguments. Closes #1826

Changeset: 4379aa405bedd6cc1d8324d84689cd4df79d837d

Note: See TracTickets for help on using tickets.