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

64-bit machine segfault on document.validate(schema) #16

Closed
CaptDowner opened this issue May 5, 2011 · 5 comments
Closed

64-bit machine segfault on document.validate(schema) #16

CaptDowner opened this issue May 5, 2011 · 5 comments

Comments

@CaptDowner
Copy link

Running code shown at: http://codeidol.com/other/rubyckbk/XML-and-HTML/Validating-an-XML-Document/ using libxml-ruby 2.0.5 on ruby 1.9.2-head produces segmentation fault on 64-bit machines. The same code works fine on 32-bit architectures.

complete irb session:

bash-/~$ irb
Loaded /home/sdownie/.irbrc successfully!
Switch to inspect mode.
ruby-1.9.2-head :001 > require 'xml/libxml'
require 'xml/libxml'
=> true
ruby-1.9.2-head :002 > dtd = XML::Dtd.new(%{
dtd = XML::Dtd.new(%{
ruby-1.9.2-head :003">

ruby-1.9.2-head :004">

ruby-1.9.2-head :005">

ruby-1.9.2-head :006">

ruby-1.9.2-head :007">

ruby-1.9.2-head :008"> })

})

=> #LibXML::XML::Dtd:0x000000014a00a0
ruby-1.9.2-head :009 > open('cookbook.xml', 'w') do |f|
open('cookbook.xml', 'w') do |f|
ruby-1.9.2-head :010 > f.write %{
f.write %{
ruby-1.9.2-head :011">

ruby-1.9.2-head :012">

ruby-1.9.2-head :013"> <title>A recipe</title>

<title>A recipe</title> ruby-1.9.2-head :014"> A difficult/common problem A difficult/common problem ruby-1.9.2-head :015"> A smart solution A smart solution ruby-1.9.2-head :016"> A deep solution A deep solution ruby-1.9.2-head :017"> Pointers Pointers ruby-1.9.2-head :018"> ruby-1.9.2-head :019"> ruby-1.9.2-head :020"> } } ruby-1.9.2-head :021?> end end => 266 ruby-1.9.2-head :022 > document = XML::Document.file('cookbook.xml') document = XML::Document.file('cookbook.xml') => <title>A recipe</title> A difficult/common problem A smart solution A deep solution Pointers

ruby-1.9.2-head :023 > document.validate(dtd)
document.validate(dtd)
=> true
ruby-1.9.2-head :024 > schema = XML::Schema.from_string %{
schema = XML::Schema.from_string %{
ruby-1.9.2-head :025">

ruby-1.9.2-head :026"> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
ruby-1.9.2-head :027"> <xsd:element name="recipe" type="recipeType"/>
<xsd:element name="recipe" type="recipeType"/>
ruby-1.9.2-head :028">

ruby-1.9.2-head :029"> <xsd:element name="rubycookbook" type="rubycookbookType"/>
<xsd:element name="rubycookbook" type="rubycookbookType"/>
ruby-1.9.2-head :030">

ruby-1.9.2-head :031"> <xsd:element name="title" type="xsd:string"/>
<xsd:element name="title" type="xsd:string"/>
ruby-1.9.2-head :032"> <xsd:element name="problem" type="xsd:string"/>
<xsd:element name="problem" type="xsd:string"/>
ruby-1.9.2-head :033"> <xsd:element name="solution" type="xsd:string"/>
<xsd:element name="solution" type="xsd:string"/>
ruby-1.9.2-head :034"> <xsd:element name="discussion" type="xsd:string"/>
<xsd:element name="discussion" type="xsd:string"/>
ruby-1.9.2-head :035"> <xsd:element name="seealso" type="xsd:string"/>
<xsd:element name="seealso" type="xsd:string"/>
ruby-1.9.2-head :036">

ruby-1.9.2-head :037"> <xsd:complexType name="rubycookbookType">
<xsd:complexType name="rubycookbookType">
ruby-1.9.2-head :038"> xsd:sequence
xsd:sequence
ruby-1.9.2-head :039"> <xsd:element ref="recipe"/>
<xsd:element ref="recipe"/>
ruby-1.9.2-head :040"> /xsd:sequence
/xsd:sequence
ruby-1.9.2-head :041"> /xsd:complexType
/xsd:complexType
ruby-1.9.2-head :042"> <xsd:complexType name="recipeType">
<xsd:complexType name="recipeType">
ruby-1.9.2-head :043"> xsd:sequence
xsd:sequence
ruby-1.9.2-head :044"> <xsd:element ref="title"/>
<xsd:element ref="title"/>
ruby-1.9.2-head :045"> <xsd:element ref="problem"/>
<xsd:element ref="problem"/>
ruby-1.9.2-head :046"> <xsd:element ref="solution"/>
<xsd:element ref="solution"/>
ruby-1.9.2-head :047"> <xsd:element ref="discussion"/>
<xsd:element ref="discussion"/>
ruby-1.9.2-head :048"> <xsd:element ref="seealso"/>
<xsd:element ref="seealso"/>
ruby-1.9.2-head :049"> /xsd:sequence
/xsd:sequence
ruby-1.9.2-head :050"> /xsd:complexType
/xsd:complexType
ruby-1.9.2-head :051">

ruby-1.9.2-head :052"> /xsd:schema
/xsd:schema
ruby-1.9.2-head :053"> }
}
=> #LibXML::XML::Schema:0x00000001619710
ruby-1.9.2-head :054 >

ruby-1.9.2-head :055 > document.validate(schema)
document.validate(schema)
(irb):55: [BUG] Segmentation fault
ruby 1.9.2dev (2010-05-20 revision 27928) [x86_64-linux]

-- control frame ----------
c:0024 p:---- s:0086 b:0086 l:000085 d:000085 CFUNC :validate
c:0023 p:0014 s:0082 b:0082 l:0017a8 d:000081 EVAL (irb):55
c:0022 p:---- s:0080 b:0080 l:000079 d:000079 FINISH
c:0021 p:---- s:0078 b:0078 l:000077 d:000077 CFUNC :eval
c:0020 p:0028 s:0071 b:0071 l:000070 d:000070 METHOD /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/workspace.rb:80
c:0019 p:0033 s:0064 b:0063 l:000062 d:000062 METHOD /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/context.rb:254
c:0018 p:0031 s:0058 b:0058 l:001f88 d:000057 BLOCK /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:159
c:0017 p:0042 s:0050 b:0050 l:000049 d:000049 METHOD /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:273
c:0016 p:0011 s:0045 b:0045 l:001f88 d:000044 BLOCK /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:156
c:0015 p:0144 s:0041 b:0041 l:000024 d:000040 BLOCK /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/ruby-lex.rb:243
c:0014 p:---- s:0038 b:0038 l:000037 d:000037 FINISH
c:0013 p:---- s:0036 b:0036 l:000035 d:000035 CFUNC :loop
c:0012 p:0009 s:0033 b:0033 l:000024 d:000032 BLOCK /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/ruby-lex.rb:229
c:0011 p:---- s:0031 b:0031 l:000030 d:000030 FINISH
c:0010 p:---- s:0029 b:0029 l:000028 d:000028 CFUNC :catch
c:0009 p:0023 s:0025 b:0025 l:000024 d:000024 METHOD /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/ruby-lex.rb:228
c:0008 p:0046 s:0022 b:0022 l:001f88 d:001f88 METHOD /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:155
c:0007 p:0011 s:0019 b:0019 l:0009f8 d:000018 BLOCK /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:70
c:0006 p:---- s:0017 b:0017 l:000016 d:000016 FINISH
c:0005 p:---- s:0015 b:0015 l:000014 d:000014 CFUNC :catch
c:0004 p:0183 s:0011 b:0011 l:0009f8 d:0009f8 METHOD /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:69
c:0003 p:0177 s:0006 b:0006 l:001508 d:002458 EVAL /home/sdownie/.rvm/rubies/ruby-1.9.2-head/bin/irb:17
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH

c:0001 p:0000 s:0002 b:0002 l:001508 d:001508 TOP

-- Ruby level backtrace information ----------------------------------------
/home/sdownie/.rvm/rubies/ruby-1.9.2-head/bin/irb:17:in <main>' /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:69:instart'
/home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:69:in catch' /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:70:inblock in start'
/home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb.rb:155:in eval_input' /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/context.rb:254:inevaluate'
/home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/workspace.rb:80:in evaluate' /home/sdownie/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/irb/workspace.rb:80:ineval'
(irb):55:in irb_binding' (irb):55:invalidate'

-- C level backtrace information -------------------------------------------
irb(rb_vm_bugreport+0xa9) [0x518e59]
irb() [0x5599a6]
irb(rb_bug+0xb1) [0x559b41]
irb() [0x4aaf40]
/lib64/libpthread.so.0() [0x327aa0f4a0]
/usr/lib64/libxml2.so.2(xmlValidateOneElement+0x23e) [0x3f8e26ccde]
/usr/lib64/libxml2.so.2(xmlValidateElement+0x6a) [0x3f8e26d8da]
/usr/lib64/libxml2.so.2(xmlValidateDtd+0x9a) [0x3f8e26dc6a]
/home/sdownie/.rvm/gems/ruby-1.9.2-head/gems/libxml-ruby-2.0.5/lib/libxml_ruby.so(+0xffc8) [0x7f50e59dcfc8]
irb() [0x50f481]
irb() [0x510b66]
irb() [0x515459]
irb() [0x515eb2]
irb(rb_f_eval+0xd6) [0x516466]
irb() [0x50f481]
irb() [0x510b66]
irb() [0x515459]
irb() [0x517ca9]
irb(rb_rescue2+0x15b) [0x41789b]
irb() [0x5040f9]
irb() [0x50f481]
irb() [0x510b66]
irb() [0x515459]
irb() [0x5167ee]
irb(rb_catch_obj+0xbe) [0x502d5e]
irb() [0x50401a]
irb() [0x50f481]
irb() [0x510b66]
irb() [0x515459]
irb() [0x5167ee]
irb(rb_catch_obj+0xbe) [0x502d5e]
irb() [0x50401a]
irb() [0x50f481]
irb() [0x510b66]
irb() [0x515459]
irb(rb_iseq_eval_main+0x28a) [0x51587a]
irb() [0x417c12]
irb(ruby_run_node+0x36) [0x419826]
irb(main+0x49) [0x416e19]
/lib64/libc.so.6(__libc_start_main+0xfd) [0x327a21ec5d]
irb() [0x416d09]

[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

Aborted (core dumped)


Let me know if additional information is required.

HTH,

-- Steve

@cfis
Copy link
Member

cfis commented May 5, 2011

Hi Capt,

So this commit yesterday fixed a similar sounding issue:

59da46e

That was the only real change in 2.0.5. So just to verify, this was without a double using version 2.0.5 and not 2.0.4? Also it looks like it worked the first time you called doc.validate(dtd) but failed the second time?

Charlie

Charlie

@cfis cfis closed this as completed May 5, 2011
@cfis cfis reopened this May 5, 2011
@cfis
Copy link
Member

cfis commented May 5, 2011

Ok, I now see in the trace it was 2.0.5, so skip that.

What OS is this?

Charlie

@CaptDowner
Copy link
Author

Charlie,

What OS is this?

Linux, Fedora Core 13

bash-/~$ uname -a
Linux localhost.localdomain 2.6.34.8-68.fc13.x86_64 #1 SMP Thu Feb 17 15:03:58 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

It doesn't happen on 32 bit architecture(s), with the exact same calling sequence.

And, on a 64-bit machine, it happens when I use document.validate(schema), and it's fine on the call to document.validate(dtd)

It sounds like a type misalignment, 32 bit versus 64 bit. The differing size of ints and pointers can collide.

HTH,

Captain Downer
Sea of Anarchy Yacht Club

On Thu, 5 May 2011 15:51:57 -0700
cfis reply@reply.github.com wrote:

Ok, I now see in the trace it was 2.0.5, so skip that.

What OS is this?

Charlie

Reply to this email directly or view it on GitHub:
#16 (comment)

@cfis
Copy link
Member

cfis commented May 6, 2011

Hi Captain Downer (quite a name),

I'm testing on a 64 bit box, Fedora 14.

Anyway, I see the issue. For schemas, use Document#validate_schema, not Document#validate. The validate method assumes that it is getting a DTD, not an xml schema.

So I think this is ok as-is...

@CaptDowner
Copy link
Author

Charlie,

Thanks for the tip. And thanks for your work on the XML stuff. It rocks!

I only stumbled on the 64 bit problem when I was running the code on the web site I referenced in the bug report. I've recently has a request to acquire some XML chops, so while I'm a coding veteran, some of this is new for me.

Document#validate_schema it is.

Steve Downie

aka Captain Downer
Sea of Anarchy Yacht Club

On Thu, 5 May 2011 18:49:38 -0700
cfis reply@reply.github.com wrote:

Hi Captain Downer (quite a name),

I'm testing on a 64 bit box, Fedora 14.

Anyway, I see the issue. For schemas, use Document#validate_schema, not Document#validate. The validate method assumes that it is getting a DTD, not an xml schema.

So I think this is ok as-is...

Reply to this email directly or view it on GitHub:
#16 (comment)

@cfis cfis closed this as completed Jun 23, 2011
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