#1723: [bug] linked lists result in segfaults
----------------------+-----------------------------------------------------
 Reporter:  pmichaud  |       Owner:       
     Type:  bug       |      Status:  new  
 Priority:  normal    |   Milestone:       
Component:  none      |     Version:  2.6.0
 Severity:  medium    |    Keywords:       
     Lang:            |       Patch:       
 Platform:            |  
----------------------+-----------------------------------------------------
 Creating a linked list of moderate size ultimately leads to a segfault
 during GC.

 The following program simply creates a linked list of nodes.  On my
 system, I get a segfault after about 96K nodes:
 {{{
 pmich...@plum:~/parrot/trunk$ cat list2.pir
 .sub 'main' :main
     .local pmc iterclass, intclass

     iterclass = newclass ['RangeIter']
     addattribute iterclass, '$!value'
     addattribute iterclass, '$!nextIter'
     intclass = subclass ['Integer'], 'Int'

     .local pmc head, next
     head = new iterclass
     $P0 = new intclass
     setattribute head, '$!value', $P0

     next = head
   loop:
     ($I0, next) = next.'reify'()
     $I1 = $I0 % 5000
     if $I1 goto loop
     say $I0
     goto loop
 .end


 .namespace ['RangeIter']

 .sub 'reify' :method
     .local pmc value, nextiter
     value = getattribute self, '$!value'
     nextiter = new ['RangeIter']
     setattribute self, '$!nextIter', nextiter
     $P0 = add value, 1.0
     setattribute nextiter, '$!value', $P0
     .return ($P0, nextiter)
 .end
 pmich...@plum:~/parrot/trunk$ ./parrot list2.pir
 5000
 10000
 15000
 20000
 25000
 30000
 35000
 40000
 45000
 50000
 55000
 60000
 65000
 70000
 75000
 80000
 85000
 90000
 95000
 Segmentation fault
 pmich...@plum:~/parrot/trunk$
 }}}

 gdb shows that the segfault occurs in gc mark:

 {{{
 Program received signal SIGSEGV, Segmentation fault.
 0x00007ffff7a5d7e5 in Parrot_gc_mark_PMC_alive_fun (interp=0x60a080,
     obj=0x3418e80) at src/gc/api.c:166
 }}}


 Some Rakudo users have reported segfaults on lists with less than 10,000
 nodes.

 Pm

-- 
Ticket URL: <https://trac.parrot.org/parrot/ticket/1723>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets

Reply via email to