From: transfire@... Date: 2006-07-09T00:37:53+09:00 Subject: Re: libhxml Node#remove! kills each loop and extension to #<< Matthew Smillie wrote: > I'm not aware (and couldn't find) any libhxml - if you meant ruby- > libxml (which seems likely given the problem), here's what I figured > out. :) Yes libxml bindings is indeed what I was refering (h was a typo) > At first, I thought it could be a bug caused by modification to the > structure you're iterating over, similar to this: > > root = ['a','b','c'] > root.each { |node| root.delete(node) if node == "b" } > > which will skip over 'c' due to the deletion. > > But while I was trying to confirm this in libxml, I found behaviour > that makes me think there's some more fundamental bug. Redefining a > variable seemed to have some very odd effects, which I managed to > reduce to this case: [snip] > => > > # where did *this* come from? > > > (That's the existing definition of #<<, not your extension) > > Exiting from the irb session results in a segmentation fault, and > running the same code outside of irb yields the same apparent results > (inclusion of 'b' where it shouldn't be), and resulted in a bus > error. I have the hunch that the C extension isn't managing memory > properly, which is confirmed by one of the errors submitted on the > project page. Maybe this is just my setup (1.8.4 on OSX), but it > seems to me that the library has enough problems that it's not quite > ready for use. Thanks matthew. Very enlightening. I decdided to write a xml wrapper and create an common interface for either REXML and libxml. That way I can use REXML for now and easy switch over when libxml binding are fully operational. T.