Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Multithreaded Kernel#trap -> __jtrap #226

Closed
dekz opened this Issue · 2 comments

2 participants

@dekz

When trying to kick off Rack::Servers in different threads, I run into a bit of a weird race condition issue which only happens on Jruby-1.6.7. It seems that the Rack::Server#start calls a trap(:INT) which invokes Kernel#trap to call __jtrap in Jruby land. Only I get a NoMethodError when the RubyKernel#trap calls __jtrap.

I've got a test here which can reproduce (on both linux and OSX) using jdk1.6. Testing in jruby-1.7.0-preview seems to work.

Here is the offending java code RubyKernel#trap.

Simply retrying will eventually 'work' and __jtrap can be found it seems, but retrying until it works seems incorrect. A simple global lock cannot work in this situation as Rack::Server#start doesn't return to return the hold on the lock until end.

@dekz

Speculating that the __jtrap method hasn't been loaded, so the first thread goes to load, second sees it's loaded and tries to use (and fails).

Calling:

trap(:INT) do
  puts 'b'
end
# Do other threaded trap

before the threads are created seems to alleviate the issue.

@headius
Owner

This code was rewritten and moved mostly into Ruby for JRuby 1.7.0. The given script works fine now.

@headius headius closed this
@graaff graaff referenced this issue in seattlerb/minitest
Closed

minitest 5.0.x tests fail with jruby 1.6.x #322

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.