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

ThreadKill not handled by ThreadFiber #2773

Closed
e2 opened this Issue Mar 28, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@e2
Copy link

e2 commented Mar 28, 2015

Celluloid tests are failing consistently on JRuby (jruby-1.7.19 and jruby-head from RVM) with stacks like the following:

Exception in thread "Ruby-0-Fiber-3" org.jruby.exceptions.ThreadKill
        at org.jruby.RubyThread.throwThreadKill(RubyThread.java:517)
        at org.jruby.RubyThread.checkMail(RubyThread.java:216)
        at org.jruby.RubyThread.pollThreadEvents(RubyThread.java:513)
        at org.jruby.RubyThread.pollThreadEvents(RubyThread.java:509)
        at org.jruby.RubyThread.executeBlockingTask(RubyThread.java:1064)
        at org.jruby.RubyThread.wait_timeout(RubyThread.java:1413)
        at org.jruby.ext.thread.Queue.pop(Queue.java:152)
        at org.jruby.ext.thread.Queue.pop(Queue.java:127)
        at org.jruby.ext.thread.SizedQueue.pop(SizedQueue.java:111)
        at org.jruby.ext.fiber.ThreadFiber$1.run(ThreadFiber.java:214)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)

On jruby-head it's:

Exception in thread "Ruby-0-Fiber-1" org.jruby.exceptions.ThreadKill
        at org.jruby.RubyThread.throwThreadKill(RubyThread.java:625)
        at org.jruby.RubyThread.toKill(RubyThread.java:274)
        at org.jruby.RubyThread.executeInterrupts(RubyThread.java:243)
        at org.jruby.RubyThread.pollThreadEvents(RubyThread.java:615)
        at org.jruby.RubyThread.executeTask(RubyThread.java:1363)
        at org.jruby.ext.thread.Queue.pop(Queue.java:195)
        at org.jruby.ext.thread.Queue.pop(Queue.java:164)
        at org.jruby.ext.fiber.ThreadFiber$1.run(ThreadFiber.java:250)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)

Isn't ThreadFiber.run supposed to catch and handle ThreadKill?

Let me know if I can debug further (though coming up with a specific short snippet may be hard).

@headius

This comment has been minimized.

Copy link
Member

headius commented Mar 29, 2015

Yes, we probably should just be handling it there, since it needs to propagate out of the fiber into the owning thread.

@headius headius closed this in 8d7c1b1 Mar 29, 2015

headius added a commit that referenced this issue Mar 29, 2015

@headius headius added this to the JRuby 1.7.20 milestone Mar 29, 2015

@headius

This comment has been minimized.

Copy link
Member

headius commented Mar 29, 2015

If you can come up with a way to test this, it would be great. Perhaps something that spins up a bunch of threads with fibers and kills them.

@e2

This comment has been minimized.

Copy link
Author

e2 commented Mar 29, 2015

I'm not sure why/how the fibers are getting killed, actually. Running the Celluloid tests off of master or 0-16-stable fails pretty much every time on JRuby. The "probe_spec.rb" is pretty much what consistently causes this error (though the spec is complex as it is).

It seems to be failing randomly in an "after" block - where celluloid is shut down (tasks are killed, etc.). There's a bit too much stuff there going on for me to create a simple failing example with JRuby. Though the Celluoid tests fail pretty much every time.

I don't get the JRuby side of the threads are interrupted (the flags and stuff) to even being to find where it's failing on the Celluloid side (where the fibers are killed/interrupted).

I thought about just catching the exception in JRuby and throwing any Ruby exception - just to get idea of where the exception is happening.

I'm not even sure how to kill a fiber to begin with...

@e2

This comment has been minimized.

Copy link
Author

e2 commented Mar 29, 2015

I'll test the fix and let you know (building jruby-head will take a while).

@e2

This comment has been minimized.

Copy link
Author

e2 commented Mar 29, 2015

Cool! The tests now hang sometimes, but ... no crashes so far!

I'm marking this as closed.

Thanks, you're awesome! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.