From: Mauricio Fernandez Date: 2006-09-05T01:18:03+09:00 Subject: Re: rcov & Ruby 1.8.5 On Fri, Sep 01, 2006 at 02:16:58PM +0900, John Carter wrote: > Is it my fevered imagination, or has Ruby-1.8.5 clobbered rcov-0.7.0, > causing it to segfault. AFAIK it works with ruby 1.8.5 (I just ran it on Pimki's tests to make sure) [1]. > Here is a backtrace... > #0 coverage_mark_caller () at rcovrt.c:81 [...] > > Looking in coverage_mark_caller () at rcovrt.c:81 > for (; frame && (n = frame->node); frame = frame->prev) { > if (frame->prev && frame->prev->last_func) { > if (frame->prev->node == n) continue; > coverage_increase_counter_uncached(n->nd_file, nd_line(n) > - 1, 1); > } > else { > -line 81--> coverage_increase_counter_uncached(n->nd_file, nd_line(n) > - 1, 1); > } > break; > } > > if I print out n, it's value is (NODE *) 0x2 This code was mostly taken from eval.c's backtrace(). It was changed on Jul 24, but the modification doesn't seem to imply that the above would segfault under 1.8.5. At any rate, here's the patch to mirror the new backtrace(): diff -rN -u old-head/ext/rcovrt/rcovrt.c new-head/ext/rcovrt/rcovrt.c --- old-head/ext/rcovrt/rcovrt.c 2006-09-04 16:46:46.000000000 +0200 +++ new-head/ext/rcovrt/rcovrt.c 2006-09-04 16:46:46.000000000 +0200 @@ -74,7 +74,9 @@ } for (; frame && (n = frame->node); frame = frame->prev) { if (frame->prev && frame->prev->last_func) { - if (frame->prev->node == n) continue; + if (frame->prev->node == n) { + if (frame->prev->last_func == frame->last_func) continue; + } coverage_increase_counter_uncached(n->nd_file, nd_line(n) - 1, 1); } else { I wouldn't expect that to prevent the segfault (which I cannot reproduce anyway), but that's the only patch I can think of right now. We're looking for either: * a bug in coverage_mark_caller due to my misunderstanding of backtrace()'s code in eval.c * a genuine bug in Ruby (why would a frame->node == 2) * something caused by a buggy extension (the usual suspect used to be syck, but it's gotten better as of late ;-) Is there any way to reproduce the segfault? [1] 1.8.5 breaks rcov in pure-Ruby mode, but I don't think anybody is using it anyway, since it's over 100 times slower... I'll try to fix that though. -- Mauricio Fernandez - http://eigenclass.org - singular Ruby