# A sure way to crash JRuby with Nokogiri, on Windows

**URL:** <https://www.ruby-forum.com/t/a-sure-way-to-crash-jruby-with-nokogiri-on-windows/185862>\
**Category:** Ruby\
**Created:** [March 27, 2010, 6:16pm UTC](https://www.ruby-forum.com/t/a-sure-way-to-crash-jruby-with-nokogiri-on-windows/185862 "2010-03-27T18:16:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luchp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/779978/32.png) [@luchp](https://www.ruby-forum.com/u/luchp)\
**Post date:** [March 27, 2010, 6:16pm UTC](https://www.ruby-forum.com/t/a-sure-way-to-crash-jruby-with-nokogiri-on-windows/185862/1 "2010-03-27T18:16:33Z")

</div>

Greetings,

I’m sending this to Ruby-talk because I’m really not sure if the problem  
is in JRuby, Nokogiri or FFI.

So, Using JRuby 1.4.0 (standard or complete) and Nokogiri-java 1.4.1, on  
Windows, try this:

require “rubygems”  
require “nokogiri”  
xml = %Q(\<?xml version="1.0" encoding="UTF-8"?\>\n\n)  
p Nokogiri::XML::Document.parse(xml)

It works.

Now try this:

require “rubygems”  
require “nokogiri”  
th = Thread.new do  
xml = %Q(\<?xml version="1.0" encoding="UTF-8"?\>\n\n)  
p Nokogiri::XML::Document.parse(xml)  
end  
th.join

And see it crash with an EXCEPTION\_ACCESS\_VIOLATION. Here’s the top of  
the stack:

Stack: [0x03260000,0x032b0000], sp=0x032aedb4, free space=315k  
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code,  
C=native code)  
C [ntdll.dll+0x1b21a]  
C [ntdll.dll+0x1046]  
j com.kenai.jffi.Foreign.invokeVrI(J)I+0  
j com.kenai.jffi.Invoker.invokeVrI(Lcom/kenai/jffi/Function;)I+8  
j  
org.jruby.ext.ffi.jffi.FastIntMethodZeroArg.call(Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/RubyModule;Ljava/lang/String;)Lorg/jruby/runtime/builtin/IRubyObject;+12  
J  
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/RubyClass;Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;)Lorg/jruby/runtime/builtin/IRubyObject;  
J  
org.jruby.runtime.callsite.CachingCallSite.call(Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/builtin/IRubyObject;)Lorg/jruby/runtime/builtin/IRubyObject;  
J  
org.jruby.ast.CallNoArgNode.interpret(Lorg/jruby/Ruby;Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/Block;)Lorg/jruby/runtime/builtin/IRubyObject;  
J  
org.jruby.ast.NewlineNode.interpret(Lorg/jruby/Ruby;Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/Block;)Lorg/jruby/runtime/builtin/IRubyObject;  
J  
org.jruby.ast.BlockNode.interpret(Lorg/jruby/Ruby;Lorg/jruby/runtime/ThreadContext;Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/Block;)Lorg/jruby/runtime/builtin/IRubyObject;

This works just fine on OS X. Anyone has any idea what the problem is?

---

<div class="post-metadata">

**Author:** ![luchp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/779978/32.png) [@luchp](https://www.ruby-forum.com/u/luchp)\
**Post date:** [March 28, 2010, 9:43am UTC](https://www.ruby-forum.com/t/a-sure-way-to-crash-jruby-with-nokogiri-on-windows/185862/2 "2010-03-28T09:43:17Z")

</div>

Have you tried 1.5.0 builds? There have been a lot of fixes since 1.4.  
[ci.jruby.org/snapshots](http://ci.jruby.org/snapshots)

(sorry for brevity sent from ps3)

- Charlie

---

<div class="post-metadata">

**Author:** ![luchp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/779978/32.png) [@luchp](https://www.ruby-forum.com/u/luchp)\
**Post date:** [March 29, 2010, 3:45pm UTC](https://www.ruby-forum.com/t/a-sure-way-to-crash-jruby-with-nokogiri-on-windows/185862/3 "2010-03-29T15:45:18Z")

</div>

I’ll take a look. I’ve commented on the JRuby ticket as well.

On Sun, Mar 28, 2010 at 3:42 AM, Charles Oliver N.

---

<div class="post-metadata">

**Author:** ![luchp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/779978/32.png) [@luchp](https://www.ruby-forum.com/u/luchp)\
**Post date:** [March 31, 2010, 8:36am UTC](https://www.ruby-forum.com/t/a-sure-way-to-crash-jruby-with-nokogiri-on-windows/185862/4 "2010-03-31T08:36:40Z")

</div>

On Sat, Mar 27, 2010 at 1:15 PM, Luc H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Greetings,
> 
> I’m sending this to Ruby-talk because I’m really not sure if the problem is  
> in JRuby, Nokogiri or FFI.
> 
> So, Using JRuby 1.4.0 (standard or complete) and Nokogiri-java 1.4.1, on  
> Windows, try this:

> This works just fine on OS X. Anyone has any idea what the problem is?

This appears to be an issue with the libxml2 DLL shipped with Nokogiri’s  
JRuby gem.

You can follow along at:  
[http://github.com/tenderlove/nokogiri/issues/#issue/248](http://github.com/tenderlove/nokogiri/issues/#issue/248)
