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 when using Node#<<( attr_node ) #558

Closed
Phrogz opened this issue Nov 1, 2011 · 2 comments
Closed

Segfault when using Node#<<( attr_node ) #558

Phrogz opened this issue Nov 1, 2011 · 2 comments

Comments

@Phrogz
Copy link

Phrogz commented Nov 1, 2011

Repro code:

require 'nokogiri'
p Nokogiri::VERSION, RUBY_DESCRIPTION
r = Nokogiri.XML('<r a="1" />').root
r << r.at_xpath('@a').remove

Result:

"1.5.0"
"ruby 1.9.2p180 (2011-02-18) [i386-mingw32]"
C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.0-x86-mingw32/lib/nokogiri/xml/node.rb:270: [BUG] Segmentation fault
ruby 1.9.2p180 (2011-02-18) [i386-mingw32]

-- control frame ----------
c:0006 p:---- s:0019 b:0019 l:000018 d:000018 CFUNC  :add_child_node
c:0005 p:0060 s:0015 b:0015 l:000014 d:000014 METHOD C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.0-x86-mingw32/lib/nokogiri/xml/node.rb:270
c:0004 p:0013 s:0011 b:0011 l:000010 d:000010 METHOD C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.0-x86-mingw32/lib/nokogiri/xml/node.rb:283
c:0003 p:0088 s:0007 b:0007 l:001e9c d:0009d8 EVAL   C:/Users/gkistner.NVIDIA.COM/Desktop/tmp2.rb:4
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001e9c d:001e9c TOP   
---------------------------
-- Ruby level backtrace information ----------------------------------------
C:/Users/gkistner.NVIDIA.COM/Desktop/tmp2.rb:4:in `<main>'
C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.0-x86-mingw32/lib/nokogiri/xml/node.rb:283:in `<<'
C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.0-x86-mingw32/lib/nokogiri/xml/node.rb:270:in `add_child'
C:/Ruby/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.0-x86-mingw32/lib/nokogiri/xml/node.rb:270:in `add_child_node'

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html


This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
@Phrogz
Copy link
Author

Phrogz commented Nov 1, 2011

Damn, that was fast! :) Given a Node and an Attr, what's the recommended way to 'add' the attribute to the node? Only:

node[attr.name] = attr.value

?

@tenderlove
Copy link
Member

Off the top of my letlagged head, that's the only API I can think of that will do it. I can't think of something that accepts a straight Nokogiri::XML::Attr node. @flavorjones?

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

2 participants