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
Use of deprecated Thread.stop() causes ThreadDeath exceptions propagating to caller #1183
Comments
We should be handling those stop exceptions and not allowing them to get out into Ruby proper. |
👍 |
Until this is fixed, any suggested workaround to try in my Ruby code? |
Experiencing the same issue here. My setup
|
I'm not sure if this is the same problem but I can reproduce thread death quite consistently:
|
jruby-1_7 branch started failing on travis-ci with these lately e.g. :
probably smt changed on travis' end (re-running a green build gets red) but still seems like there might be something to fix on JRuby's end ... note that 9K builds do not seem to exhibit the behavior. |
This also affects our rake-invoked Spec tests of our Puppet code under JRuby. |
I'll have a look. Probably fixed in 9k. |
Ok, I can reproduce the message...but it isn't actually killing anything. The exception occurs within threads that are intended to die a horrible, flaming death. I suspect the problem is just that we don't have a default exception handler on these threads, and the ThreadDeath fires outside the exception handling bits. There's a couple options...none of them super great:
This is not fixed in 9k, but it likely doesn't show up as often because UNIX platforms no longer use this logic for subprocess management. It may be easy to still reproduce it in 9k on Windows. |
For what it's worth, wouldn't a more supported approach be to use But maybe doing interrupts correctly is difficult in this code, I obviously don't know the specifics. |
We use JRuby on Windows and I just for the first time saw the ol' ThreadDeath since switching to the 9k branch. This is not intentionally trying to elicit it, just showing up as unexpected output from one of our scripts. We updated to 9.1.5.0 today, but it may be complete coincidence that it cropped up for the first time. |
I thought I did some work on this. Let me see... |
Ahh, right...as I mentioned above, this may never happen on a posix system because we use different logic for IO that doesn't require "pump" threads to keep buffered IO streams flowing (a nasty requirement of the JVM's troublesome Process API. This is further reason why we (read: I) need to bite the bullet and get native IO and process management working on Windows. Let's see how much we can borrow from @djberg96's excellent projects...starting to wonder if we should just throw up our hands and admit he's done it right already. |
This needs to go into 9.2 or earlier, but it will never be in 1.7.x. |
Link with #4112. |
This has become less of a priority since most subprocess launching uses native posix_spawn logic now. I still think we need to revisit it but it won't be done for 9.2.0.0. |
These stop calls were put in place during a time when the "pump" threads were not easily interrupted. Usually this was due to being forced to work with opaque IO streams rather than the actual channels. At this point, with Thread#stop going away and still causing log noise, we have decided to remove all calls. This code was used primarily by the few remaining non-popen-based command launches (usually which read the streams to completion and do not need to be interrupted), and for much of IO on Windows (since we have not finished porting native IO logic to Windows). If the removal of these calls leads to leaky pump threads, we will find an alternative way or prioritize the completion of native IO on Windows.
These stop calls were put in place during a time when the "pump" threads were not easily interrupted. Usually this was due to being forced to work with opaque IO streams rather than the actual channels. At this point, with Thread#stop going away and still causing log noise, we have decided to remove all calls. This code was used primarily by the few remaining non-popen-based command launches (usually which read the streams to completion and do not need to be interrupted), and for much of IO on Windows (since we have not finished porting native IO logic to Windows). If the removal of these calls leads to leaky pump threads, we will find an alternative way or prioritize the completion of native IO on Windows.
This was originally at: https://jira.codehaus.org/browse/JRUBY-7074
A change introduced in jruby 1.6.8 is a call (well, three calls) to the deprecated Thread.stop() method in org.jruby.util.ShellLauncher.handleStreams(). This causes a problem in an embedded interpreter that runs ruby scripts which in turn start a shell due to ThreadDeath exceptions being propagated up into the embedding code. Should the jruby framework itself be catching and dealing with any cleanup resulting from these exceptions? Or perhaps the use of deprecated methods should be reviewed?
The text was updated successfully, but these errors were encountered: