-
-
Notifications
You must be signed in to change notification settings - Fork 922
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
Output unreliable from spawned processes #779
Comments
Now that rails runs CI tests against JRuby I see that the rails generator tests are hitting this problem. You can see the failures here: https://travis-ci.org/rails/rails/jobs/9807848 When I run output = capture(:stdout){ Rails::Generators.invoke :model, [] }
assert_match(/Description:/, output) in irb things work as expected but when run in those tests some of the stdout is not captured and some is. I'm guessing this is related because the generators seem to spawn processes The implementation of Not sure if there's maybe some change we can make to capture to be more reliable or if we need to actually fix the subprocess launching in jruby. |
#967 may also be related. |
Injecting a little sleep, as short as 50ms, seems effective. In the example in #781, on my MBA, it was able to run through 8000+ iterations without errors. |
I don't know when I should use Jira or Github. I began to write here.
Subversion commands work fine, but with Git doesn't work normally "Bad File Descriptor". |
I have modified a bit this method:
Everything works fine. I'm a newbie with Ruby but I'm studying the differences and his relation with the JRuby Subprocess. |
SCM tests fail randomly due to IO.popen(). See: jruby/jruby#779 git-svn-id: http://svn.redmine.org/redmine/trunk@12875 e93f8b46-1217-0410-a6f0-8f06a7374b81
since #781 has been closed in reference to this issue: I have been bit with the loop do
puts("#{i}") if (i += 1) % 100 == 0
f = IO.popen(["echo", "foobar"], "r+")
f.readlines
f.close rescue puts($!.inspect)
end It typically generates a few exceptions every hundred invocations. changing mode from |
SCM tests fail randomly due to IO.popen(). See: jruby/jruby#779 git-svn-id: http://svn.redmine.org/redmine@12875 e93f8b46-1217-0410-a6f0-8f06a7374b81
This bug (thanks Java!) is the reason Redmine's SCM integration breaks when running under JRuby - http://www.redmine.org/boards/1/topics/38861 . @headius has written about this before but I'm not sure there's much that can help since he wrote http://blog.headius.com/2013/06/the-pain-of-broken-subprocess.html |
Hit the issue on elasticsearch/logstash again using jruby 1.7.{17,19}. |
JRuby 9000 has completely rewritten process-spawning logic to match MRI (direct ports in many cases, but using posix_spawn). I would be surprised if it's not considerably more reliable now since we're routing around the JDK's nonsense. Going to optimistically call this fixed in 9k. |
(This is probably a known issue, but I didn't see a issue for it. I wanted to document it here so that I can refer to in the tags I'm going to add to the specs it affects.)
There seems to be a race to capture the output of spawned processes in the tests. The race is lost much more often on Linux, but can also manifest itself on Mac.
Looking at the code, it smells like this might be due to how the
output_to_fd
matcher works in combination with the known race conditions which also lead to the inappropriate echild errors. Haven't been able to prove that yet though...Anyhow, here's a summary of how exactly this manifests in the tests:
Here's a case from Travis where the output goes to the test's stdout rather than being consumed by the test
(from this log). Note how the
foo
the test is outputting is appended to the test output (element to a Stringfoo
) rather than being received by the test matcher, which gets""
:Alternatively, there are also cases where a previous test's output is still around to be consumed by the next test (from this log). Note how the directory listing which is the output of
subjects the specified command to shell expansion
(which passed) interferes with thefoo
thatcalls #to_str to convert the argument to a String
is trying to validate:Hopefully that isn't too verbose and helps a bit... a pull tagging specs which are susceptible to this is on its way.
The text was updated successfully, but these errors were encountered: