From: Markus Date: 2004-09-01T00:13:13+09:00 Subject: Re: (Revised) [PATCH] Subtle bug in bignum.c On Tue, 2004-08-31 at 07:59, ts wrote: > >>>>> "M" == Markus writes: > > M> I've always thought (but remember, I don't really know C) that volatile > M> was a hint to the compiler that code that _used_ something should _not_ > M> hold it in a register, because something else might modify it at any > M> time (e.g. the system clock). So I am not sure why it would help. > > Yes, you are right. > > Now `x' and `y' will not be in a register, and ruby will find it on the > stack if the GC is called in bignew() *even* if a new Bignum is created by > rb_big_clone() and stored at this address. > > The initial problem is that the new Bignum (created by rb_big_clone()) was > stored in a register (because `x' was in a register), then the content of > the register was replaced with another variable (RBIGNUM(y)->digits) when > the gc was called and this is why ruby was unable to mark the Bignum > > > Guy Decoux Ah yes. Thank you. I had not realized (but should have guessed) that the gc walked the stack to find things that were reachable. I will work up & test a third (and I hope final) patch. The only remaining question is: do you think there may be analogous bugs lurking elsewhere in the code? I suppose it might be possible to hunt for them in a semi-automated way, but before I embark on that is there any reason to suppose that this situation is more or less common? -- Markus