OpenStruct, OpenObject both seg fault, this does not, anything wrong?

Ok, I am using 1.8.6 p110 with rails 1.2.5 and I use alot of
OpenStructs.
Well, it seg faults pretty regularly:

0.upto(100) {|n| member.driver_process_member}
/usr/lib/ruby/1.8/ostruct.rb:75: [BUG] Segmentation fault
ruby 1.8.6 (2007-09-23) [i686-linux]

So I tried ruby 1.8.5, same thing.
So I tried OpenObject in the facets lib, seg faults in a different
place now:

member = Account.get(6).member;0.upto(100) {|n| member.driver_process_member}
/usr/lib/ruby/gems/1.8/gems/facets-2.1.1/lib/more/facets/openobject.rb:
183: [BUG] Segmentation fault
ruby 1.8.5 (2006-08-25) [i686-linux]

class HashDot < Hash
def method_missing(sym, arg=nil)
type = sym.to_s[-1,1]
key = sym.to_s.sub(/[=?!]$/,’’).to_sym
if type == “=”
self[key] = arg
return self[key]
else
return self[key]
end
end
end

So I created this minimalist class that extends hash, and it does not
segfault.
The questions are:

  • how to figure out what’s wrong with OpenStruct (I am not a gdb guy
    but could follow instructions)
  • why is the source for OpenStruct and OpenObject so complicated
    (compared to HashDot)?

On Nov 16, 3:40 pm, “[email protected][email protected] wrote:

place now:
key = sym.to_s.sub(/[=?!]$/,‘’).to_sym
segfault.
The questions are:

  • how to figure out what’s wrong with OpenStruct (I am not a gdb guy
    but could follow instructions)
  • why is the source for OpenStruct and OpenObject so complicated
    (compared to HashDot)?

They both remove as many Kernel methods as they possibly can in order
to make the objects as “open” as possible. So my guess is, this must
be arising from a method that Ruby is expecting to exist (as public)
but that both classes are clobbering. The question then is which one.
To help out this is what OpenObject does.

PUBLIC_METHODS = /(^__|^instance_|^object_|^\W|^as$|^send$|^class$|?
$)/

protected *public_instance_methods.select{ |m| m !~ PUBLIC_METHODS }

T.