ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:69961] [Ruby trunk - Bug #11350] [Open] When Process.exec failed, redirections were still changed and not restored
       [not found] <redmine.issue-11350.20150714042741@ruby-lang.org>
@ 2015-07-14  4:27 ` ngotogenome
  2015-07-14  4:54 ` [ruby-core:69962] [Ruby trunk - Bug #11350] [Feedback] " akr
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ngotogenome @ 2015-07-14  4:27 UTC (permalink / raw)
  To: ruby-core

Issue #11350 has been reported by Naohisa Goto.

----------------------------------------
Bug #11350: When Process.exec failed, redirections were still changed and not restored
https://bugs.ruby-lang.org/issues/11350

* Author: Naohisa Goto
* Status: Open
* Priority: Normal
* Assignee: Nobuyoshi Nakada
* ruby -v: 
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
When Process.exec failed, redirections of file descriptors were changed and not restored.

When redirecting fd 3 or 5, ASYNC BUG occurred as below.

~~~
$ ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 3=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
[ASYNC BUG] consume_communication_pipe: read

EBADF

ruby 2.3.0dev (2015-07-13) [sparc64-solaris2.10]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

stdout: #<Errno::ENOENT: No such file or directory - /does_not_exist>
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>Abort
~~~

~~~
$ ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 5=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
[ASYNC BUG] consume_communication_pipe: read

EBADF

ruby 2.3.0dev (2015-07-13) [sparc64-solaris2.10]

stdout: [NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

#<Errno::ENOENT: No such file or directory - /does_not_exist>
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>Abort
~~~



When redirecting fd 1 or 2 to /dev/null, stdout or stderr is still redirected to /dev/null and the printed contents are not shown.

~~~
% ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 1=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>
~~~

~~~
% ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 2=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
stdout: #<Errno::ENOENT: No such file or directory - /does_not_exist>
~~~

All of the above are observed both on x86_64 Linux and sparc Solaris.

Is this spec or bug?




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:69962] [Ruby trunk - Bug #11350] [Feedback] When Process.exec failed, redirections were still changed and not restored
       [not found] <redmine.issue-11350.20150714042741@ruby-lang.org>
  2015-07-14  4:27 ` [ruby-core:69961] [Ruby trunk - Bug #11350] [Open] When Process.exec failed, redirections were still changed and not restored ngotogenome
@ 2015-07-14  4:54 ` akr
  2015-07-14  6:03 ` [ruby-core:69963] [Ruby trunk - Bug #11350] [Open] " ngotogenome
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: akr @ 2015-07-14  4:54 UTC (permalink / raw)
  To: ruby-core

Issue #11350 has been updated by Akira Tanaka.

Status changed from Open to Feedback

It is an example of the documented behavior described as follows.

```
 *  The modified attributes may be retained when <code>exec(2)</code> system
 *  call fails.
 *
 *  For example, hard resource limits are not restorable.
 *
 *  Consider to create a child process using ::spawn or Kernel#system if this
 *  is not acceptable.
```

It is possible to restore FDs if there are free FDs enough.
But It is a tired task.  

----------------------------------------
Bug #11350: When Process.exec failed, redirections were still changed and not restored
https://bugs.ruby-lang.org/issues/11350#change-53394

* Author: Naohisa Goto
* Status: Feedback
* Priority: Normal
* Assignee: Nobuyoshi Nakada
* ruby -v: 
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
When Process.exec failed, redirections of file descriptors were changed and not restored.

When redirecting fd 3 or 5, ASYNC BUG occurred as below.

~~~
$ ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 3=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
[ASYNC BUG] consume_communication_pipe: read

EBADF

ruby 2.3.0dev (2015-07-13) [sparc64-solaris2.10]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

stdout: #<Errno::ENOENT: No such file or directory - /does_not_exist>
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>Abort
~~~

~~~
$ ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 5=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
[ASYNC BUG] consume_communication_pipe: read

EBADF

ruby 2.3.0dev (2015-07-13) [sparc64-solaris2.10]

stdout: [NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

#<Errno::ENOENT: No such file or directory - /does_not_exist>
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>Abort
~~~



When redirecting fd 1 or 2 to /dev/null, stdout or stderr is still redirected to /dev/null and the printed contents are not shown.

~~~
% ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 1=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>
~~~

~~~
% ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 2=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
stdout: #<Errno::ENOENT: No such file or directory - /does_not_exist>
~~~

All of the above are observed both on x86_64 Linux and sparc Solaris.

Is this spec or bug?




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:69963] [Ruby trunk - Bug #11350] [Open] When Process.exec failed, redirections were still changed and not restored
       [not found] <redmine.issue-11350.20150714042741@ruby-lang.org>
  2015-07-14  4:27 ` [ruby-core:69961] [Ruby trunk - Bug #11350] [Open] When Process.exec failed, redirections were still changed and not restored ngotogenome
  2015-07-14  4:54 ` [ruby-core:69962] [Ruby trunk - Bug #11350] [Feedback] " akr
@ 2015-07-14  6:03 ` ngotogenome
  2015-07-14  8:58 ` [ruby-core:69964] [Ruby trunk - Bug #11350] " ngotogenome
  2015-07-14 14:31 ` [ruby-core:69967] " ngotogenome
  4 siblings, 0 replies; 6+ messages in thread
From: ngotogenome @ 2015-07-14  6:03 UTC (permalink / raw)
  To: ruby-core

Issue #11350 has been updated by Naohisa Goto.

Status changed from Feedback to Open
Assignee deleted (Nobuyoshi Nakada)

> Consider to create a child process using ::spawn or Kernel#system if this is
> not acceptable.

I think so, and I agree this is a spec.

I think the documentation should be added about the risk of ASYNC BUG when redirecting FDs that Ruby timer thread internally uses.

PS.
It seems that Japanese documentation of Process.exec does not describe about the limitation. (but this is not a bug of Ruby itself)
http://docs.ruby-lang.org/ja/2.2.0/class/Process.html#S_EXEC

----------------------------------------
Bug #11350: When Process.exec failed, redirections were still changed and not restored
https://bugs.ruby-lang.org/issues/11350#change-53395

* Author: Naohisa Goto
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
When Process.exec failed, redirections of file descriptors were changed and not restored.

When redirecting fd 3 or 5, ASYNC BUG occurred as below.

~~~
$ ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 3=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
[ASYNC BUG] consume_communication_pipe: read

EBADF

ruby 2.3.0dev (2015-07-13) [sparc64-solaris2.10]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

stdout: #<Errno::ENOENT: No such file or directory - /does_not_exist>
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>Abort
~~~

~~~
$ ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 5=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
[ASYNC BUG] consume_communication_pipe: read

EBADF

ruby 2.3.0dev (2015-07-13) [sparc64-solaris2.10]

stdout: [NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

#<Errno::ENOENT: No such file or directory - /does_not_exist>
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>Abort
~~~



When redirecting fd 1 or 2 to /dev/null, stdout or stderr is still redirected to /dev/null and the printed contents are not shown.

~~~
% ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 1=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>
~~~

~~~
% ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 2=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
stdout: #<Errno::ENOENT: No such file or directory - /does_not_exist>
~~~

All of the above are observed both on x86_64 Linux and sparc Solaris.

Is this spec or bug?




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:69964] [Ruby trunk - Bug #11350] When Process.exec failed, redirections were still changed and not restored
       [not found] <redmine.issue-11350.20150714042741@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2015-07-14  6:03 ` [ruby-core:69963] [Ruby trunk - Bug #11350] [Open] " ngotogenome
@ 2015-07-14  8:58 ` ngotogenome
  2015-07-14  9:17   ` [ruby-core:69965] " Eric Wong
  2015-07-14 14:31 ` [ruby-core:69967] " ngotogenome
  4 siblings, 1 reply; 6+ messages in thread
From: ngotogenome @ 2015-07-14  8:58 UTC (permalink / raw)
  To: ruby-core

Issue #11350 has been updated by Naohisa Goto.


To avoid ASYNC BUG, is it possible to close timer-thread pipe after stopping the timer thread, and when Process.exec fails, to open the timer-thread pipe again before re-starting the timer thread?


----------------------------------------
Bug #11350: When Process.exec failed, redirections were still changed and not restored
https://bugs.ruby-lang.org/issues/11350#change-53396

* Author: Naohisa Goto
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
When Process.exec failed, redirections of file descriptors were changed and not restored.

When redirecting fd 3 or 5, ASYNC BUG occurred as below.

~~~
$ ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 3=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
[ASYNC BUG] consume_communication_pipe: read

EBADF

ruby 2.3.0dev (2015-07-13) [sparc64-solaris2.10]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

stdout: #<Errno::ENOENT: No such file or directory - /does_not_exist>
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>Abort
~~~

~~~
$ ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 5=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
[ASYNC BUG] consume_communication_pipe: read

EBADF

ruby 2.3.0dev (2015-07-13) [sparc64-solaris2.10]

stdout: [NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

#<Errno::ENOENT: No such file or directory - /does_not_exist>
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>Abort
~~~



When redirecting fd 1 or 2 to /dev/null, stdout or stderr is still redirected to /dev/null and the printed contents are not shown.

~~~
% ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 1=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>
~~~

~~~
% ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 2=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
stdout: #<Errno::ENOENT: No such file or directory - /does_not_exist>
~~~

All of the above are observed both on x86_64 Linux and sparc Solaris.

Is this spec or bug?




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:69965] Re: [Ruby trunk - Bug #11350] When Process.exec failed, redirections were still changed and not restored
  2015-07-14  8:58 ` [ruby-core:69964] [Ruby trunk - Bug #11350] " ngotogenome
@ 2015-07-14  9:17   ` Eric Wong
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Wong @ 2015-07-14  9:17 UTC (permalink / raw)
  To: Ruby developers

ngotogenome@gmail.com wrote:
> To avoid ASYNC BUG, is it possible to close timer-thread pipe after
> stopping the timer thread, and when Process.exec fails, to open the
> timer-thread pipe again before re-starting the timer thread?

Yes.  And we should always lazy start the timer thread to avoid
wasting resources on single-threaded scripts.

If nobody else does this soon, I will try it in a few weeks (currently
busy with other stuff).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:69967] [Ruby trunk - Bug #11350] When Process.exec failed, redirections were still changed and not restored
       [not found] <redmine.issue-11350.20150714042741@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2015-07-14  8:58 ` [ruby-core:69964] [Ruby trunk - Bug #11350] " ngotogenome
@ 2015-07-14 14:31 ` ngotogenome
  4 siblings, 0 replies; 6+ messages in thread
From: ngotogenome @ 2015-07-14 14:31 UTC (permalink / raw)
  To: ruby-core

Issue #11350 has been updated by Naohisa Goto.


On UNIX-like systems, native_stop_timer_thread(int close_anyway) in thread_pthread.c stops the timer thread, and if "int close_anyway" is true, it should close the communication pipe. However, currently, it does not close the pipe even if close_anyway is true.
TODO is described in the comment lines of the source.

~~~
	/* close communication pipe */
	if (close_anyway) {
	    /* TODO: Uninstall all signal handlers or mask all signals.
	     *       This pass is cleaning phase (terminate ruby process).
	     *       To avoid such race, we skip to close communication
	     *       pipe.  OS will close it at process termination.
	     *       It may not good practice, but pragmatic.
	     *       We remain it is TODO.
	     */
	    /* close_communication_pipe(); */
	}
~~~


----------------------------------------
Bug #11350: When Process.exec failed, redirections were still changed and not restored
https://bugs.ruby-lang.org/issues/11350#change-53399

* Author: Naohisa Goto
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
When Process.exec failed, redirections of file descriptors were changed and not restored.

When redirecting fd 3 or 5, ASYNC BUG occurred as below.

~~~
$ ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 3=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
[ASYNC BUG] consume_communication_pipe: read

EBADF

ruby 2.3.0dev (2015-07-13) [sparc64-solaris2.10]

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

stdout: #<Errno::ENOENT: No such file or directory - /does_not_exist>
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>Abort
~~~

~~~
$ ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 5=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
[ASYNC BUG] consume_communication_pipe: read

EBADF

ruby 2.3.0dev (2015-07-13) [sparc64-solaris2.10]

stdout: [NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

#<Errno::ENOENT: No such file or directory - /does_not_exist>
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>Abort
~~~



When redirecting fd 1 or 2 to /dev/null, stdout or stderr is still redirected to /dev/null and the printed contents are not shown.

~~~
% ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 1=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
stderr: #<Errno::ENOENT: No such file or directory - /does_not_exist>
~~~

~~~
% ruby -e 'begin; Process.exec("/does_not_exist", "arg", { 2=>["/dev/null", "w"]}); rescue Errno::ENOENT => e; $stdout.print "stdout: ", e.inspect, "\n"; $stderr.print "stderr: ", e.inspect, "\n"; end'
stdout: #<Errno::ENOENT: No such file or directory - /does_not_exist>
~~~

All of the above are observed both on x86_64 Linux and sparc Solaris.

Is this spec or bug?




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-07-14 14:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-11350.20150714042741@ruby-lang.org>
2015-07-14  4:27 ` [ruby-core:69961] [Ruby trunk - Bug #11350] [Open] When Process.exec failed, redirections were still changed and not restored ngotogenome
2015-07-14  4:54 ` [ruby-core:69962] [Ruby trunk - Bug #11350] [Feedback] " akr
2015-07-14  6:03 ` [ruby-core:69963] [Ruby trunk - Bug #11350] [Open] " ngotogenome
2015-07-14  8:58 ` [ruby-core:69964] [Ruby trunk - Bug #11350] " ngotogenome
2015-07-14  9:17   ` [ruby-core:69965] " Eric Wong
2015-07-14 14:31 ` [ruby-core:69967] " ngotogenome

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).