chicken-janitors
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-janitors] #866: gc goes crazy with faulty finalizers


From: Chicken Trac
Subject: [Chicken-janitors] #866: gc goes crazy with faulty finalizers
Date: Wed, 13 Jun 2012 08:46:22 -0000

#866: gc goes crazy with faulty finalizers
---------------------+------------------------------------------------------
 Reporter:  megane   |       Owner:       
     Type:  defect   |      Status:  new  
 Priority:  major    |   Milestone:  4.9.0
Component:  unknown  |     Version:  4.7.x
 Keywords:           |  
---------------------+------------------------------------------------------
 {{{
 ;; It seems like the gc stops working correctly after an exception
 ;; from a faulty finalizer gets caught (and not crash the whole
 ;; program).

 (define n 2000000000)
 (define vector-size 100)

 (define (make-objects n gc-msg)
   (let loop [(i 0)]
     (let [(o (make-vector vector-size))]
       (print "making " i)
       (set-finalizer! o (lambda (ob) (print gc-msg " " i)))
       (if (< i n)
           (loop (+ 1 i))))))

 (set-finalizer! (make-vector 100) (lambda (ob) (+ i 'a)))
 (handle-exceptions
     exn
   (begin
     (print "Caught an exception" exn))
   (make-objects n "gc'ing"))

 (print "done")

 ;; Result when compiled: 3 cases

 ;; Case 1: out of memory, tweak n, vector-size to avoid this
 ;; ...
 ;; [panic] out of memory - cannot allocate heap segment - execution
 terminated

 ;; Case 2:  100% cpu with no apparent progress

 ;; Output with -:g
 ;; ...
 ;; [GC] 2 finalized item(s) still pending
 ;; [GC] 2680 finalizer value(s) marked
 ;; [GC] level  1        gcs(minor)  379 gcs(major)  22
 ;; [GC] stack   0xbfef7880      0xbff36a00      0xbff37880
 ;; [GC]  from   0x773d9008      0xb731f744      0xb73d9000      0x3ff4673c
 ;; [GC]    to   0x09123008      0x09123008      0x49123000
 ;; [GC] 0 locatives (from 32)
 ;; 681
 ;; [GC] 2 finalized item(s) still pending
 ;; [GC] 2681 finalizer value(s) marked
 ;; [GC] level  1        gcs(minor)  0   gcs(major)  23
 ;; [GC] stack   0xbfef7880      0xbff36a00      0xbff37880
 ;; [GC]  from   0x09123008      0x490cb1d8      0x49123000      0x3ffa81d0
 ;; [GC]    to   0x773d9008      0x773d9008      0xb73d9000
 ;; [GC] 0 locatives (from 32)
 ;; <- stuck here with 100% cpu

 ;; Case 3: 100% at the end
 ;; making 1
 ;; making 2
 ;; ...
 ;; ...
 ;; gc'ing 103
 ;; gc'ing 102
 ;; gc'ing 101
 ;; Caught an exception#<condition: (exn type)>
 ;; done
 ;; <- stuck here with 100% cpu


 }}}

-- 
Ticket URL: <http://bugs.call-cc.org/ticket/866>
Chicken Scheme <http://www.call-with-current-continuation.org/>
Chicken Scheme is a compiler for the Scheme programming language.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]