From: Nathaniel Talbott Date: 2000-12-29T05:36:31+09:00 Subject: [ruby-talk:8195] Re: Inexplicable core dump > > I have some code that looks like this: > > > > 14 def update(channel, value=nil) > > 15 @channels[channel].each { > > 16 | key, proc | > > 17 if (proc.arity == 0) > > 18 proc.call > > 19 else > > 20 proc.call(value) > > 21 end > > 22 } if ( ! @channels[channel].nil? ) > > 23 end > > > > The first time it gets called in my code where proc.arity != > > 0 (i.e. it goes > > into the else branch) it does one of these: > > > > ./Tuner.rb:20: [BUG] Segmentation fault > > ruby 1.6.2 (2000-12-25) [i686-cygwin] > > 0 [sig] ruby 120 stackdump: Dumping stack trace > > to ruby.exe.stackdump > > Aborted (core dumped) > > Hmmm... well, I have some more info. First of all, the bug > came back, so the > blank line fix didn't really fix things. I've dug into it a > bit more, and it > looks like I was sort of barking up the wrong tree. Things > are core dumping > AFTER the proc returns. Turns out it always core dumps after > calling the > same proc. Here's the proc (well, it's really a method; passed with > &method(:resultChanged), which might have some bearing, but > I'm not sure): > > def resultChanged(result) > @result = result > $defout.write(".") > end > > It's kind of complex, but basically this only fails if I've written > something large out (using puts) somewhere else. The core > dump seems to be > caused somehow by the return value value of the method (which > is always 1 as > far as I can tell) because this always (at least so far) works: > > def resultChanged(result) > @result = result > $defout.write(".") > return nil > end Aargh! I was wrong. The method is not being called. I was confused by the '.' I was writing out and the one Ruby puts out when it prints a backtrace, such as './Tuner.rb : 23'. Clearly my dots were crossed. Back to square one. Ruby is dying intermittently (and can be fixed temporarily by changing the code in the files) when I 'proc.call' where proc is a method converted to a proc by &method(:theMethod). Ideas? Nathaniel <:((>< + - - + - - | RoleModel Software, Inc. & | EQUIP VI | The XP Software Studio(TM) |