30 Jul 14:48
Re: Suggested patch for Open Dylan's C runtime
From: Thomas Christian Chust <chust <at> web.de>
Subject: Re: Suggested patch for Open Dylan's C runtime
Newsgroups: gmane.comp.lang.dylan.gwydion.devel
Date: 2007-07-30 12:48:56 GMT
Subject: Re: Suggested patch for Open Dylan's C runtime
Newsgroups: gmane.comp.lang.dylan.gwydion.devel
Date: 2007-07-30 12:48:56 GMT
Bruce Hoult wrote: > On 7/30/07, Hannes Mehnert <hannes <at> mehnert.org> wrote: > >> I just commited that patch to the subversion repository. Thanks a lot. > > This patch appears to put finalized objects onto a queue for later > running, rather than running them from within the GC. Good! > > BUT .. it does a GC_NEW() from within the finalizer, which is called > from within the GC. Therefore the GC is entered recursively. This is > very very bad and will bite you one day and you won't know why. Hello, I must admit that I don't know the Boehm garbage collector's internals well enough to decide for sure whether allocation from a finalizer is safe or not. In case the allocation functions hold some mutex locks this could indeed break horribly. But anyway, I think this is about the only way to force the Boehm garbage collector into an approximately correct behaviour for finalization queues: If I don't put the object pointer into a queue allocated with the garbage collector, it gets discarded immediately after the finalizer has run. Thus I must first make the pointer live again by putting it into a block of memory allocated with the collector. Once the queue has been drained, the queue memory itself and the objects referenced from it will be eligible for collection again, unless the Dylan finalizers resurrect some objects once more. The only acceptable alternative I can think of that avoids allocation in the C-level finalizer would be to preallocate an array list to use as the finalization queue. But that would pose an artificial size limit on the finalization queue. cu, Thomas -- -- Gd-hackers mailing list Gd-hackers <at> gwydiondylan.org https://www.opendylan.org/mailman/listinfo/gd-hackers
RSS Feed