segfault during mark-and-sweep GC
- From: Aubrey Jaffer <agj@xxxxxxxxxxxx>
- Date: Thu, 27 Aug 2009 13:27:42 -0400
The STRESS-GC-MARK procedure constructs a list where the CAR of each
pair is the same as its CDR. This causes the mark phase of some
mark-and-sweep garbage collectors to exceed the CPU stack limit in their
depth-first traversal of pairs.
;;; (stress-gc-mark 999999) causes a segfault in SCM and MIT-Scheme
;;; running on an Intel CPU.
(define (stress-gc-mark len)
(do ((cnt (+ -1 len) (+ -1 cnt))
(lst '() (cons lst lst)))
((negative? cnt) lst)))
(define foo (stress-gc-mark 999999))
How do other implementations avoid or solve this vulnerability?