From: Nathaniel Talbott Date: 2000-12-29T01:25:27+09:00 Subject: [ruby-talk:8178] 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) OK, I thought maybe there was a bug in my version of Ruby (I didn't have the stable version of 1.6.2 initially), so I recompiled. Still core dumped. So, next I figured maybe my code was fruity, so I added an extra check to my code: 14 def update(channel, value=nil) 15 @channels[channel].each { 16 | key, proc | 17 if (proc.arity == 0) 18 proc.call 19 else if ( proc.arity == 1 || proc.arity == -1 ) 20 proc.call(value) 21 else 22 puts("Bad arity: #{proc.arity}") 23 end 24 } if ( ! @channels[channel].nil? ) 25 end The code now ran flawlessly, but the puts wasn't being called! In other words, the same code was being run, but it wasn't core dumping anymore. So, I started fiddling with things to see what would and wouldn't run. I eventually came to find out that this ran great: 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 22 end 23 } if ( ! @channels[channel].nil? ) 24 end Which is exactly what I started with plus a blank line at 21! I'm completely clueless. If I remove that blank line, things still core dump. Anybody have any idea what this is or how to fix it? Let me know if there's any more info that would be helpful (version info is in the core dump above; I'm running Windows 2000). TIA, Nathaniel <:((>< + - - + - - | RoleModel Software, Inc. & | EQUIP VI | The XP Software Studio(TM) |