On Wed, 2004-10-20 at 09:04, Lee wrote:
> Hi Everyone,
> 
> I have just installed Ruby under Windows painlessly
> and successfully:
> 
> --
> oe:~/My Documents/ruby 70>ruby -v
> ruby 1.8.2 (2004-10-15) [i386-cygwin]
> --
> 
> I then attempted to install ruby-htmltools and received
> the following output when running 'ruby install.rb install':
> 
> --
> [several successful tests snipped] 
>   1) Error:
> test_match1(XPathTestCase):
> SystemStackError: stack level too deep
>     /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:220:in `internal_parse'
>     /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:49:in `match'
>     /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:303:in `d_o_s'
>     /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:301:in `each_index'
>     /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:301:in `d_o_s'
>     /usr/local/lib/ruby/1.8/rexml/xpath_parser.rb:294:in `descendant_or_self'
> [the above 6 stack frames repeated many times snipped]
> 
>   2) Error:
> test_match_all(XPathTestCase):
> SystemStackError: stack level too deep
> [the same repeating stack frames snipped]
> 
>   3) Error:
> test_show_attribute(XPathTestCase):
> SystemStackError: stack level too deep
> [the same repeating stack frames snipped]
> 
> 6 tests, 7 assertions, 0 failures, 3 errors
> install failed
> hook /usr/local/src/ruby-htmltools/./pre-install.rb failed:
> 'system /usr/local/bin/ruby -Ilib /usr/local/src/ruby-htmltools/test/tc_xpath.rb' failed
> try 'ruby install.rb --help' for usage
> 
> --
> 
> 
> If anyone can give me suggestions for successfully installing ruby-htmltools
> under Cygwin, I would be very appreciative. (I'm completely new to ruby, but
> I'm used to jumping through all sorts of hoops to install Perl modules under
> cygwin, so this stumbling block hasn't dimmed my enthusiasm for learning
> and using ruby yet :-)

     I don't know much about the innards of ruby-htmltools, and I don't
have a windows box, but it looks like no one else is jumping in to help
so I will take a shot at it.

     It sounds like unbounded recursion.  Generally, a recursive routine
is supposed to either pass down different arguments than it got, or
change some external state, so that eventually it will "bottom out" and
start returning results back up to the caller.  But what seems to be
happening here is that it just keeps going until the stack is full, and
then *boom*.
     What you see is the smoke trail listing the last few times it went
around the death spiral before crashing.  So let's go look at the code
in question to see if we can guess what it's doing.  (I'll be right
back...)

    This is interesting.  I was looking at the "d_o_s" code and noticed
a comment a few lines up that may bear on the situation, so I'll quote
that as well:

287   ##########################################################
288   # The next two methods are BAD MOJO!
289   # This is my achilles heel.  If anybody thinks of a better
290   # way of doing this, be my guest.  This really sucks, but
291   # it took me three days to get it to work at all.
292   #########################################################
293
294   def descendant_or_self( path_stack, nodeset )
295        rs = []
296        d_o_s( path_stack, nodeset, rs )
297        #puts "RS = #{rs.collect{|n|n.to_s}.inspect}"
298        rs.flatten.compact
299   end
300
301   def d_o_s( p, ns, r )
302        #puts r.collect{|n|n.to_s}.inspect
303        #puts ns.collect{|n|n.to_s}.inspect
304        nt = nil
305        ns.each_index do |i|
306             n = ns[i]
307             x = match( p.clone, [ n ] )
308             #puts "Got a match on #{p.inspect} for
#{ns.collect{|n|n.to_s+" ("+n.type.to_s+")"}.inspect}"
309             nt = n.node_type
310             d_o_s( p, n.children, x ) if nt == :element or nt ==
:document
311             r[i,0] = [x] if x.size > 0
312         end
313    end

      So you might try un-commenting the puts (so you can watch it on
the way down instead of just hearing a *boom* and looking at the smoke. 
Just looking at it, it looks like this would fail in the way we are
seeing if called on a circular structure, or if node_type or children
were implemented incorrectly.
     Have you checked to see if this is a known issue, or platform
specific, etc.?

    -- Markus