On 21/11/2012 5:38 PM, Graham Menhennitt wrote:
RUBY_INIT_STACK;
ruby_init();
ruby_init_loadpath();
rb_eval_string("$mutex = Mutex.new");
rb_eval_string("$mutex.synchronize(){}");
return 0;
}
I’ve done a bit more investigation and found that it happens in all 1.9
releases of Ruby, but it does NOT happen in 1.8.7.
The test program below produces:
[:locked?, :try_lock, :lock, :unlock, :sleep, :nil?, :===, :=~, :!~,
:eql?, :hash, :<=>, :class, :singleton_class, :clone, :dup,
:initialize_dup, :initialize_clone, :taint, :tainted?, :untaint,
:untrust, :untrusted?, :trust, :freeze, :frozen?, :to_s, :inspect,
:methods, :singleton_methods, :protected_methods, :private_methods,
:public_methods, :instance_variables, :instance_variable_get,
:instance_variable_set, :instance_variable_defined?, :instance_of?,
:kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?,
:respond_to_missing?, :extend, :display, :method, :public_method,
:define_singleton_method, :object_id, :to_enum, :enum_for, :==,
:equal?, :!, :!=, :instance_eval, :instance_exec, :__send__,
:id]
Whereas running “ruby -e ‘p Mutex.new.methods’” produces:
[:locked?, :try_lock, :lock, :unlock, :sleep, :synchronize, :nil?,
:===, :=~, :!~, :eql?, :hash, :<=>, :class, :singleton_class,
:clone, :dup, :initialize_dup, :initialize_clone, :taint, :tainted?,
:untaint, :untrust, :untrusted?, :trust, :freeze, :frozen?, :to_s,
:inspect, :methods, :singleton_methods, :protected_methods,
:private_methods, :public_methods, :instance_variables,
:instance_variable_get, :instance_variable_set,
:instance_variable_defined?, :instance_of?, :kind_of?, :is_a?, :tap,
:send, :public_send, :respond_to?, :respond_to_missing?, :extend,
:display, :method, :public_method, :define_singleton_method,
:object_id, :to_enum, :enum_for, :==, :equal?, :!, :!=,
:instance_eval, :instance_exec, :__send__, :__id__]
Note that “:synchronize” is missing from the former.
I’ve tried removing all gems in case one of them was doing something
strange. I’ve searched the Ruby source code, but I can’t see anything
that might cause this.
Anybody got any ideas? Should I take this to ruby.core?
Thanks,
Graham
Test program:
#include <ruby.h>
int
main(int argc, char *argv[])
{
RUBY_INIT_STACK;
ruby_init();
ruby_init_loadpath();
rb_eval_string("p Mutex.new.methods");
return 0;
}