From: why the lucky stiff Date: 2006-08-31T03:20:30+09:00 Subject: sandbox r50, here we go, loading conflicting gems --JgQwtEuHJzHdouWu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Checky. require 'sandbox' hpricot = Sandbox.new :init => [:all] hpricot.eval(%{ require 'rubygems' require_gem 'hpricot', '=0.4.47' require 'hpricot' puts Hpricot("link").search(".test") }) hpricot2 = Sandbox.new :init => [:all] hpricot2.eval(%{ require 'rubygems' require_gem 'hpricot', '=0.4' require 'hpricot' puts Hpricot("link").search(".test") }) This proves existence of a bug in Hpricot 0.4, which was extinguished in 0.4.47. The output is: link /home/why/sand/RUBY-1_8_5/lib/ruby/gems/1.8/gems/hpricot-0.4/lib/hpricot/traverse.rb:110:in `_eval': NoMethodError: undefined method `[]=' for # (Sandbox::Exception) from ./lib/sandbox.rb:19:in `eval' from test.rb:21 In other words, 0.4.47 finds the link, but 0.4 raises the MatchData exception. This new version requires a new patch. Indeed, swapping ruby_cref was the finishing touch. Be aware, some globals and constants are not yet implemented. _why --JgQwtEuHJzHdouWu Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ruby-1.8.5-crefs_exposed.patch" diff -wur ruby-1.8.5/eval.c ruby-1.8.5-top_cref_exposed/eval.c --- ruby-1.8.5/eval.c Sun Aug 6 21:43:39 2006 +++ ruby-1.8.5-top_cref_exposed/eval.c Wed Aug 30 12:46:07 2006 @@ -1061,8 +1061,8 @@ #define POP_CLASS() ruby_class = _class; \ } while (0) -static NODE *ruby_cref = 0; -static NODE *top_cref; +NODE *ruby_cref = 0; +NODE *top_cref; #define PUSH_CREF(c) ruby_cref = NEW_NODE(NODE_CREF,(c),0,ruby_cref) #define POP_CREF() ruby_cref = ruby_cref->nd_next diff -wur ruby-1.8.5/node.h ruby-1.8.5-top_cref_exposed/node.h --- ruby-1.8.5/node.h Mon Feb 13 02:10:53 2006 +++ ruby-1.8.5-top_cref_exposed/node.h Wed Aug 30 12:46:21 2006 @@ -151,6 +151,9 @@ } u3; } NODE; +extern NODE *ruby_cref; +extern NODE *top_cref; + #define RNODE(obj) (R_CAST(RNode)(obj)) #define nd_type(n) ((int)(((RNODE(n))->flags>>FL_USHIFT)&0xff)) --JgQwtEuHJzHdouWu--