[#108771] [Ruby master Bug#18816] Ractor segfaulting MacOS 12.4 (aarch64 / M1 processor) — "brodock (Gabriel Mazetto)" <noreply@...>

Issue #18816 has been reported by brodock (Gabriel Mazetto).

8 messages 2022/06/05

[#108802] [Ruby master Feature#18821] Expose Pattern Matching interfaces in core classes — "baweaver (Brandon Weaver)" <noreply@...>

Issue #18821 has been reported by baweaver (Brandon Weaver).

9 messages 2022/06/08

[#108822] [Ruby master Feature#18822] Ruby lack a proper method to percent-encode strings for URIs (RFC 3986) — "byroot (Jean Boussier)" <noreply@...>

Issue #18822 has been reported by byroot (Jean Boussier).

18 messages 2022/06/09

[#108937] [Ruby master Bug#18832] Suspicious superclass mismatch — "fxn (Xavier Noria)" <noreply@...>

Issue #18832 has been reported by fxn (Xavier Noria).

16 messages 2022/06/15

[#108976] [Ruby master Misc#18836] DevMeeting-2022-07-21 — "mame (Yusuke Endoh)" <noreply@...>

Issue #18836 has been reported by mame (Yusuke Endoh).

12 messages 2022/06/17

[#109043] [Ruby master Bug#18876] OpenSSL is not available with `--with-openssl-dir` — "Gloomy_meng (Gloomy Meng)" <noreply@...>

Issue #18876 has been reported by Gloomy_meng (Gloomy Meng).

18 messages 2022/06/23

[#109052] [Ruby master Bug#18878] parse.y: Foo::Bar {} is inconsistently rejected — "qnighy (Masaki Hara)" <noreply@...>

Issue #18878 has been reported by qnighy (Masaki Hara).

9 messages 2022/06/26

[#109055] [Ruby master Bug#18881] IO#read_nonblock raises IOError when called following buffered character IO — "javanthropus (Jeremy Bopp)" <noreply@...>

Issue #18881 has been reported by javanthropus (Jeremy Bopp).

9 messages 2022/06/26

[#109063] [Ruby master Bug#18882] File.read cuts off a text file with special characters when reading it on MS Windows — magynhard <noreply@...>

Issue #18882 has been reported by magynhard (Matth辰us Johannes Beyrle).

15 messages 2022/06/27

[#109081] [Ruby master Feature#18885] Long lived fork advisory API (potential Copy on Write optimizations) — "byroot (Jean Boussier)" <noreply@...>

Issue #18885 has been reported by byroot (Jean Boussier).

23 messages 2022/06/28

[#109083] [Ruby master Bug#18886] Struct aref and aset don't trigger any tracepoints. — "ioquatix (Samuel Williams)" <noreply@...>

Issue #18886 has been reported by ioquatix (Samuel Williams).

8 messages 2022/06/29

[#109095] [Ruby master Misc#18888] Migrate ruby-lang.org mail services to Google Domains and Google Workspace — "shugo (Shugo Maeda)" <noreply@...>

Issue #18888 has been reported by shugo (Shugo Maeda).

16 messages 2022/06/30

[ruby-core:108790] [Ruby master Bug#18811] PTY I/O not working on AIX 7.x

From: "hspem (Per-Erik Martin)" <noreply@...>
Date: 2022-06-07 07:18:01 UTC
List: ruby-core #108790
Issue #18811 has been updated by hspem (Per-Erik Martin).

File pty.c.patch added

mame (Yusuke Endoh) wrote in #note-2:
> 
> This is my impression, but the maintenance state of AIX is not good. The CI for AIX has not been working for a long time. This issue is probably unlikely to be fixed unless you provide a patch; even if a patch is created, we cannot promise that we will apply it.

I found a way to fix this. The problem seems to be a known strangeness in the AIX pty implementation. It's sensitive to in which order things are done relative closing the descriptors. It's more common that one of the processes simply hangs if you get it wrong, but apparently you can also lose output. We have had a similar problem in sshd where it would hang unless you synchronized the parent and child processes and made the child wait for the master to close the slave end before proceeding. (And I have had processes hanging in ruby's pty as well, although not as often.) So the issue seems to be when the parent process does "close(slave)" and when this happens in relation to what the child process is doing.

Adding some kind of synchronization isn't easy in ext/pty/pty.c, but there's another way:
Since AIX does not have TIOCSTTY defined, chfunc() will close "slave" and reopen the device. This means that the parent process can close its slave descriptor *before* forking, instead of afterwards. This resolves the race condition.

The patch is simple, attached.



----------------------------------------
Bug #18811: PTY I/O not working on AIX 7.x
https://bugs.ruby-lang.org/issues/18811#change-97861

* Author: hspem (Per-Erik Martin)
* Status: Feedback
* Priority: Normal
* Assignee: kanemoto (Yutaka Kanemoto)
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [powerpc-aix7.1.0]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
The attached test script simply executes a command under a PTY and captures the output and exit code.
This works on Linux (all supported versions of Redhat, Debian, Ubuntu, and SuSE) as well as Solaris 11.4 on sparc and x86.
But on AIX 7.1 - 7.3, it doesn't. This was tested with a ruby 3.1.2 that I built, but it exhibits the same behavior on other ruby versions as well, like 2.7.5 from IBM's freeware repo.

The core of the attached program is:
``` ruby
begin
  PTY.spawn($command) do |r, w, pid|
    w.close
    begin
      r.each do |line|
        puts "Got line \"#{line.chomp}\""
      end
    rescue Errno::EIO
      # ignore
    rescue => e
      $stderr.puts "Read error: #{e}"
    ensure
      Process.wait pid
    end
    $exit_status = $?.exitstatus
  end
rescue => e
  $stderr.puts "PTY.spawn error: #{e}"
end
```


This should read the output from echo but doesn't:
``` shell
# ./ptytest.rb 'echo b'
Exit status 0
# 
```
It does execute the command, but it seems it can't read the output:
``` shell
# ./ptytest.rb 'exit 3'
Exit status 3
# cat /tmp/e.txt
cat: 0652-050 Cannot open /tmp/e.txt.
# ./ptytest.rb 'echo b > /tmp/e.txt'
Exit status 0
# cat /tmp/e.txt
b
# 
```
However, the unit tests for PTY work, so how it this possible? It turns out that all the unit tests run ruby (tinyruby really), and this works:
``` shell
# ./ptytest.rb 'ruby -e "puts \"b\""'
Got line "b"
Exit status 0
# 
```
as well as this:
``` shell
# ./ptytest.rb 'ruby -e "system \"echo b\""'
Got line "b"
Exit status 0
# 
```

So I'm at a loss here. How come it works to use "ruby" but no other commands? Is there something wrong with the script? If so, why does it work on all other platforms?


---Files--------------------------------
ptytest.rb (534 Bytes)
pty.c.patch (655 Bytes)


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

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next