ruby-htmltools on cygwin - SystemStackError

L

Lee

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 :)


thanks,
Lee
 
M

Markus

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
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
 
L

Lee

Have you checked to see if this is a known issue, or platform
specific, etc.?

Hi Markus,

Thanks for the keen observations, it would be interesting to
uncomment that debugging puts and follow the stack trace -- I
did also file a bug report at the rubyforge page for ruby-htmltools.

However, in my particular case, the problem was averted (I don't
say solved since it remains unexplained!) by installing the
pre-packaged ruby binaries that cygwin makes available (it is
version 1.8.1, rather than the 1.8.2 that I had downloaded from
the ruby download site). Perhaps there is some internal change
in ruby's stackframe handling between 1.8.1 and 1.8.2 that does
not play nicely with cygwin? I wish I had time on my hands
to investigate this, but alas, I do not.

Thanks for the helpful answer,
Lee


PS As an ironic end to this particular saga, it turns out
that the HTML returned by the site that I wish to parse is
so absurdly malformed that I cannot find a single automated
tool that does not choke on it, and so I have fallen back
to using (sigh) regular expressions to "parse" it as best
I can.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top