Hi Charlie,

It's been some time since my original post, bhowever I recently found
some time to look at this properly.

I've attached 2 test scripts, both which processthis XML file:
http://gir.deefa.com/bookwise.xml. They contain a thin wrapper around
XML::Reader designed to iterate over the nodes of interest in the file.

ok.rb runs without a problem, segfault.rb triggers a segfault. The
scripts are identical, with the exception of a single uncommented puts
line in segfault.rb

It's possilbe I'm using expand() incorrectly. If that's the case, it'd
be nice to get an error that isn't a segfault.

The final attachment is copy of the backtrace from gdb.

I'm running libxml-ruby 1.1.3 and libxml2 2.7.3 on Debian.

cheers

-- James Healy <jimmy-at-deefa-dot-com>  Thu, 04 Jun 2009 01:22:12 +1000

Charlie Savage wrote:
> Hi James,
>
> Thanks for the test case and report.
>
>>   require 'rubygems'
>>   gem "libxml-ruby", "1.1.2"
>>   require 'libxml'
>>
>>   filename = File.join(File.dirname(__FILE__), "bookwise.xml")
>>   reader = LibXML::XML::Reader.string(File.read(filename))
>>
>>   while reader.read
>>
>>     if reader.node_type == LibXML::XML::Reader::TYPE_ELEMENT
>>       if reader.name == "Header"         puts reader.read_outer_xml
>>       elsif reader.name == "Product"
>>         puts reader.read_outer_xml
>>       end
>>     end
>>
>>   end
>> ---
>>
>> I'm basically attempting to grab the full text of all Header and Product
>> nodes in the input file. My actual code doesn't just puts the elements,
>> this is simply the simplest script I could make that triggers it.
>
> You might want to use XPath instead for this.
>
>> Occasionally, instead of a segfault I get a fatal error, "Opening and
>> ending tag mismatch", despite the fact the input file is valid and well
>> formed.
>
> So I tested this with libxml-ruby 1.1.2, ruby 1.8.6 (patch level 287) on  
> Windows Vista and Fedora 10 and could not reproduce.
>
>> Am I use the Reader bindings correctly? 
>
> Yes.
>
>> If I'm not, I'd appreciate a few pointers.
>
> Since I can't reproduce the problem, can you compile the bindings with  
> debug information and get a stack trace?
>
> Charlie


Attachment: ok.rb
Description: application/ruby

Attachment: segfault.rb
Description: application/ruby

(gdb) backtrace
#0  0xb7dc37f6 in *__GI_raise (sig=6) at 
../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0xb7dc6d38 in *__GI_abort () at abort.c:88
#2  0xb7dfa065 in __libc_message (do_abort=2, fmt=0xb7ebda68 "*** glibc 
detected *** %s: %s: 0x%s ***\n") at ../sysdeps/unix/sysv/linux/libc_fatal.c:173
#3  0xb7e04215 in malloc_printerr (action=2, str=0xb7ebdb60 "double free or 
corruption (!prev)", ptr=0xa65d9c8) at malloc.c:5994
#4  0xb7e05aec in *__GI___libc_free (mem=0xa65d9c8) at malloc.c:3625
#5  0xb7874205 in xmlTextReaderFreeNode (reader=0xa658eb8, cur=0xa65d9c8) at 
xmlreader.c:474
#6  0xb7874f6e in xmlTextReaderRead__internal_alias (reader=0xa658eb8) at 
xmlreader.c:1400
#7  0xb78e2415 in rxml_reader_read (self=3084323980) at ruby_xml_reader.c:418
#8  0xb7f7cf02 in call_cfunc (func=0xb78e23e0 <rxml_reader_read>, 
recv=3084323980, len=6, argc=0, argv=0x7ea3) at eval.c:5752
#9  0xb7f88333 in rb_call0 (klass=3082073500, recv=3084323980, id=7657, 
oid=7657, argc=0, argv=0x0, body=0xb7b4ab38, flags=0) at eval.c:5904
#10 0xb7f88470 in rb_call (klass=3082073500, recv=3084323980, mid=7657, argc=0, 
argv=0x0, scope=0, self=3084364640) at eval.c:6151
#11 0xb7f82b69 in rb_eval (self=3084364640, n=<value optimized out>) at 
eval.c:3492
#12 0xb7f8557c in rb_eval (self=3084364640, n=<value optimized out>) at 
eval.c:3142
#13 0xb7f881fe in rb_call0 (klass=3084462080, recv=3084364640, id=10985, 
oid=10985, argc=0, argv=0x0, body=0xb7d85150, flags=0) at eval.c:6055
#14 0xb7f88470 in rb_call (klass=3084462080, recv=3084364640, mid=10985, 
argc=0, argv=0x0, scope=2, self=3084364640) at eval.c:6151
#15 0xb7f82cd8 in rb_eval (self=3084364640, n=<value optimized out>) at 
eval.c:3513
#16 0xb7f83db4 in rb_eval (self=3084364640, n=<value optimized out>) at 
eval.c:3677
#17 0xb7f82a82 in rb_eval (self=3084364640, n=<value optimized out>) at 
eval.c:3486
#18 0xb7f85535 in rb_eval (self=3084364640, n=<value optimized out>) at 
eval.c:3177
#19 0xb7f881fe in rb_call0 (klass=3084462080, recv=3084364640, id=4001, 
oid=4001, argc=0, argv=0x0, body=0xb7d85948, flags=0) at eval.c:6055
#20 0xb7f88470 in rb_call (klass=3084462080, recv=3084364640, mid=4001, argc=0, 
argv=0x0, scope=0, self=3084478800) at eval.c:6151
#21 0xb7f82b69 in rb_eval (self=3084478800, n=<value optimized out>) at 
eval.c:3492
#22 0xb7f85ff1 in rb_eval (self=3084478800, n=<value optimized out>) at 
eval.c:3222
#23 0xb7f94817 in ruby_exec_internal () at eval.c:1641
#24 0xb7f94862 in ruby_exec () at eval.c:1661
#25 0xb7f9489f in ruby_run () at eval.c:1671
#26 0x080486ed in main (argc=Cannot access memory at address 0x7ea3) at 
main.c:48
_______________________________________________
libxml-devel mailing list
libxml-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/libxml-devel

Reply via email to