Ticket #1723 (closed bug: fixed)

Opened 11 years ago

Last modified 11 years ago

[bug] linked lists result in segfaults

Reported by: pmichaud Owned by:
Priority: normal Milestone:
Component: GC Version: 2.6.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description

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:

pmichaud@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
pmichaud@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
pmichaud@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

Change History

Changed 11 years ago by chromatic

  • component changed from none to GC

This is almost certainly the result of recursion in the mark phase of the GC exhausting the available C stack space. We'll always have some limitation in the depth of a tree of PMCs as long as we have a recursive mark, but we can get rid of recursive mark in the near future.

Changed 11 years ago by bacek

Hello.

gc_ms2 made non-recursive in gc_massacre branch at r49242. Will close ticket after merge back to trunk.

~/src/parrot (gc_massacre)$ ./parrot list2.pir 
5000
10000
15000
....
1390000
1395000
^C
~/src/parrot (gc_massacre)$ 

-- Bacek.

Changed 11 years ago by bacek

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

gc_massacre branch merged. Test added at r49281. Closing ticket.

Note: See TracTickets for help on using tickets.