Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfault on add_child_node when GC enabled #1007

Closed
canadaduane opened this issue Nov 21, 2013 · 2 comments
Closed

segfault on add_child_node when GC enabled #1007

canadaduane opened this issue Nov 21, 2013 · 2 comments

Comments

@canadaduane
Copy link

The following code snippet will (almost always) cause a segfault after calling add_child_node when ruby garbage collection is enabled:

https://gist.github.com/7602296

I've tested this on Nokogiri 1.6.0 using libxml2 2.8.0 and 2.9.1. Disabling GC prevents the segfault from occurring.

I'd like to isolate the issue further, but I'm not sure where to dig in next. Any ideas on how to approach this?

@canadaduane
Copy link
Author

Once in a while, instead of a segfault, ruby throws an exception:

/Users/duane/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/lib/nokogiri/xml/node.rb:949:in `add_child_node': node must be a Nokogiri::XML::Node (ArgumentError)
    from /Users/duane/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/lib/nokogiri/xml/node.rb:949:in `add_child_node_and_reparent_attrs'
    from /Users/duane/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/lib/nokogiri/xml/node.rb:273:in `block in add_child'
    from /Users/duane/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/lib/nokogiri/xml/node_set.rb:237:in `block in each'
    from /Users/duane/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/lib/nokogiri/xml/node_set.rb:236:in `upto'
    from /Users/duane/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/lib/nokogiri/xml/node_set.rb:236:in `each'
    from /Users/duane/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/lib/nokogiri/xml/node.rb:273:in `add_child'
    from /Users/duane/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/lib/nokogiri/xml/node.rb:288:in `<<'

When I inspect the value of the object that must be a Nokogiri::XML::Node and that is throwing the ArgumentError, I get a large integer such as "-2882299370178845946". The integer value is different each time.

@canadaduane
Copy link
Author

I currently think this is a Representable-specific issue, so I'm closing the ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant