From: nobu.nokada@... Date: 2002-02-14T18:12:47+09:00 Subject: Re: Possible bug -- ruby cvs (1.7.2 2002-02-10) interpreter seg fault Hi, At Wed, 13 Feb 2002 13:56:51 -0700, Matt Armstrong wrote: > Should Ruby ever seg fault when it runs out of memory? That is the > bug I'm most concerned about. Perhaps, you didn't see [BUG]... message at the fault, it means real stack overflow and nothing can be done. Operationg sysetm kills the program immediately. It can be trapped with sigaltstack() under POSIX system, but no way to distinguish it from other SEGV. > I do not completely understand your answer -- what is "compilation" > for Ruby? When is GC disabled in my program above? Hmm...I see that > Tempfile uses SimpleDelegator which uses eval, so is that causing a > leak? I did experiment with GC.start and it still quickly runs out of > memory. Here "compilation" means the translation from source code to internal structure. load, require and also eval do it. Accurately, it's not a leak, "leaked" memory will be freed at next GC. But in your sample the next GC has no chance to occur. > I also found a possible leak with ObjectSpace.define_finalizer. I > think the finalizer proc is never freed. (snip) > I find that this program chews up memory until it runs out (and the > CVS version of ruby then seg faults): > > loop { > string = "a" > ObjectSpace.define_finalizer(string) { > } > } Since the finalizer proc shares the context which contains the reference to the string with the loop block, the string never be freed. > Since Tempfile uses a new proc for the finalizer of each new object, > this is bad. Tempfile uses a class method `callback' to avoid it. It's not a problem. -- Nobu Nakada