[#123414] [Ruby Bug#21629] Ruby-3.4.7 fails to build using clang / llvm — "debo (David Bohman) via ruby-core" <ruby-core@...>

Issue #21629 has been reported by debo (David Bohman).

18 messages 2025/10/07

[#123433] [Ruby Misc#21630] Suggest @Earlopain for core contributor — "kddnewton (Kevin Newton) via ruby-core" <ruby-core@...>

Issue #21630 has been reported by kddnewton (Kevin Newton).

9 messages 2025/10/08

[#123484] [Ruby Bug#21640] Core Pathname is missing 3 methods / is partially-defined — "Eregon (Benoit Daloze) via ruby-core" <ruby-core@...>

Issue #21640 has been reported by Eregon (Benoit Daloze).

21 messages 2025/10/15

[#123504] [Ruby Bug#21645] Can't `require "resolve"` on Windows under Bundler without warnings — "Earlopain (Earlopain _) via ruby-core" <ruby-core@...>

Issue #21645 has been reported by Earlopain (Earlopain _).

9 messages 2025/10/20

[#123506] [Ruby Misc#21646] Propose Luke Gruber as a Ruby committer — "jhawthorn (John Hawthorn) via ruby-core" <ruby-core@...>

Issue #21646 has been reported by jhawthorn (John Hawthorn).

8 messages 2025/10/20

[#123576] [Ruby Bug#21654] Set#new calls extra methods compared to previous versions — "tenderlovemaking (Aaron Patterson) via ruby-core" <ruby-core@...>

Issue #21654 has been reported by tenderlovemaking (Aaron Patterson).

16 messages 2025/10/29

[#123582] [Ruby Bug#21655] segfault when building 3.3.10, regression from 3.3.9 — "kurly (Greg Kubaryk) via ruby-core" <ruby-core@...>

Issue #21655 has been reported by kurly (Greg Kubaryk).

15 messages 2025/10/29

[#123586] [Ruby Misc#21656] Exclude dependabot PRs from automated gem release notes — "Earlopain (Earlopain _) via ruby-core" <ruby-core@...>

Issue #21656 has been reported by Earlopain (Earlopain _).

8 messages 2025/10/29

[#123595] [Ruby Misc#21657] Question: Is Ruby 4.0 planned for December 2025 or later? — "dmitry.pogrebnoy (Dmitry Pogrebnoy) via ruby-core" <ruby-core@...>

SXNzdWUgIzIxNjU3IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGRtaXRyeS5wb2dyZWJub3kgKERtaXRy

22 messages 2025/10/29

[#123626] [Ruby Bug#21659] rstring.h error: missing initializer for field ‘len’ of ‘struct RString’ [-Werror=missing-field-initializers] starting in ruby-3.3.10 — "wsfulton (William Fulton) via ruby-core" <ruby-core@...>

SXNzdWUgIzIxNjU5IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IHdzZnVsdG9uIChXaWxsaWFtIEZ1bHRv

10 messages 2025/10/31

[ruby-core:123505] [Ruby Bug#19017] Net::HTTP may block when attempting to reuse a persistent connection

From: "dotconfig404 (Friedrich Raschwitz) via ruby-core" <ruby-core@...>
Date: 2025-10-20 15:14:19 UTC
List: ruby-core #123505
Issue #19017 has been updated by dotconfig404 (Friedrich Raschwitz).


Hi, I am not sure we should solve this in IO, the error lies more in calling eof? in the first place I would say as eof? is meant to be blocking - and currently I only see solutions that involve non-blocking calls.

The solution proposed by Josh C lacks the EOF handling, I have created an issue at the appropiate module including PR, that should be fine as a workaround, but I would love it if we could issue a SSL_peek or a SSL_read with zero length to check for handshake data instead.

I think that'd require a new method in the OpenSSL extension, at the very least it'd require some changes to ossl_ssl.c

if we can discuss what is best here I'll gladly help implementing

Maybe the issue is best fixed in the net module after all, changing the way requests are sent altogether, I am not sure. 

please see the issue
https://github.com/ruby/net-http/issues/233

and pull request
https://github.com/ruby/net-http/pull/232

----------------------------------------
Bug #19017: Net::HTTP may block when attempting to reuse a persistent connection
https://bugs.ruby-lang.org/issues/19017#change-114877

* Author: joshc (Josh C)
* Status: Open
* ruby -v: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
Ruby's Net::HTTP code performs a blocking `Net::BufferedIO#eof?` check when attempting to reuse a persistent HTTP connection. See https://github.com/ruby/ruby/blob/6b099328af2ae2d04cbfd06fedc36a19cdecd30d/lib/net/http.rb#L1573. The bug is the check can hang for up to the HTTP `read_timeout`, which is 60 seconds by default. 

The code calls `TCPSocket#wait_readable(0)` to see if the socket is readable before calling the blocking `eof?` method. However, it's possible for the socket to be readable with SSL Handshake records and no Application Data. So the call to `eof?` will process the SSL Handshake records, but hang since no Application Data is available.

The issue can be triggered if a TLS 1.3 server sends a `NewSessionTicket` sometime after Application Data is written. The attached client and server code demonstrate the problem. Note it's important that the client and server be on separate hosts otherwise `eof?` will always return immediately.

On the server, copy `Server.java` and `certs.p12` into a directory, install JDK 17, compile the server and run it:

```
$ openssl pkcs12 -info -in certs.p12 -noout -passin pass:password
MAC: sha1, Iteration 2048
MAC length: 20, salt length: 8
PKCS7 Encrypted data: pbeWithSHA1And40BitRC2-CBC, Iteration 2048
Certificate bag
PKCS7 Data
Shrouded Keybag: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 2048
$ sudo apt install -y openjdk-17-jdk openjdk-17-jre
$ javac Server.java
$ java -Djavax.net.debug=ssl,verbose Server
Loaded pkcs12
```

On the client, copy `http.rb` and `ca.pem` into a directory, add the IP address for the server as `pluto` to `/etc/hosts`:

```
$ file ca.pem

$ sudo vi /etc/hosts
...
192.168.0.10 pluto
...
$ ruby --version
ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-linux]
$ openssl version
OpenSSL 1.1.1f  31 Mar 2020
```

Run the client to make the first request:

```
$ ruby http.rb
opening connection to pluto:8888...
opened
starting SSL for pluto:8888...
```

The server will handle request_1 and trigger a new session ticket:

```
javax.net.ssl|DEBUG|10|main|2022-09-22 18:18:23.269 UTC|SSLCipher.java:466|jdk.tls.keyLimits:  entry = AES/GCM/NoPadding KeyUpdate 2^37. AES/GCM/NOPADDING:KEYUPDATE = 137438953472
Connected to 37532
Handling request_0
... snip ...
javax.net.ssl|DEBUG|10|main|2022-09-22 18:18:25.310 UTC|SSLCipher.java:2024|KeyLimit write side: algorithm = AES/GCM/NOPADDING:KEYUPDATE
countdown value = 137438953472
javax.net.ssl|DEBUG|10|main|2022-09-22 18:18:25.335 UTC|SSLCipher.java:1870|KeyLimit read side: algorithm = AES/GCM/NOPADDING:KEYUPDATE
countdown value = 137438953472
read body
updated session data
javax.net.ssl|ALL|10|main|2022-09-22 18:18:25.343 UTC|SSLSocketImpl.java:1564|trigger new session ticket
wrote response
Handling request_1
```

The client will hang when trying to reuse the persistent connection:

```
OSSL_DEBUG: SSL SESSION new callback added [ossl_ssl.c:963]
SSL established, protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384
<- "POST / HTTP/1.1\r\nAccept-Encoding: identity\r\nConnection: keep-alive\r\nContent-Type: text/plain\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: pluto:8888\r\nContent-Length: 0\r\n\r\n"
<- ""
OSSL_DEBUG: SSL SESSION new callback entered [ossl_ssl.c:454]
-> "HTTP/1.1 200 OK\r\n"
-> "Content-Length: 0\r\n"
-> "\r\n"
reading 0 bytes...
-> ""
read 0 bytes
Conn keep-alive
OSSL_DEBUG: SSL SESSION new callback entered [ossl_ssl.c:454]
```

Pressing Ctrl-C shows the backtrace:

```
^CTraceback (most recent call last):
	11: from http.rb:10:in `<main>'
	10: from /home/josh/.rbenv/versions/2.7.6/lib/ruby/2.7.0/net/http.rb:933:in `start'
	 9: from http.rb:17:in `block in <main>'
	 8: from /home/josh/.rbenv/versions/2.7.6/lib/ruby/2.7.0/net/http.rb:1294:in `post'
	 7: from /home/josh/.rbenv/versions/2.7.6/lib/ruby/2.7.0/net/http.rb:1506:in `send_entity'
	 6: from /home/josh/.rbenv/versions/2.7.6/lib/ruby/2.7.0/net/http.rb:1492:in `request'
	 5: from /home/josh/.rbenv/versions/2.7.6/lib/ruby/2.7.0/net/http.rb:1518:in `transport_request'
	 4: from /home/josh/.rbenv/versions/2.7.6/lib/ruby/2.7.0/net/http.rb:1573:in `begin_transport'
	 3: from /home/josh/.rbenv/versions/2.7.6/lib/ruby/2.7.0/net/protocol.rb:134:in `eof?'
	 2: from /home/josh/.rbenv/versions/2.7.6/lib/ruby/2.7.0/openssl/buffering.rb:300:in `eof?'
	 1: from /home/josh/.rbenv/versions/2.7.6/lib/ruby/2.7.0/openssl/buffering.rb:57:in `fill_rbuff'
/home/josh/.rbenv/versions/2.7.6/lib/ruby/2.7.0/openssl/buffering.rb:57:in `sysread': Interrupt
```

I get the same behavior with latest ruby too:

```
$ ruby --version   
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
```

Changing Net::HTTP to the following:

```
elsif @socket.io.read_nonblock(0, exception: false).nil?
```

Resolves the issue:

```
$ ruby http.rb
opening connection to pluto:8888...
opened
starting SSL for pluto:8888...
OSSL_DEBUG: SSL SESSION new callback added [ossl_ssl.c:963]
SSL established, protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384
<- "POST / HTTP/1.1\r\nAccept-Encoding: identity\r\nConnection: keep-alive\r\nContent-Type: text/plain\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: pluto:8888\r\nContent-Length: 0\r\n\r\n"
<- ""
OSSL_DEBUG: SSL SESSION new callback entered [ossl_ssl.c:454]
-> "HTTP/1.1 200 OK\r\n"
-> "Content-Length: 0\r\n"
-> "\r\n"
reading 0 bytes...
-> ""
read 0 bytes
Conn keep-alive
<- "POST / HTTP/1.1\r\nAccept-Encoding: identity\r\nConnection: keep-alive\r\nContent-Type: text/plain\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: pluto:8888\r\nContent-Length: 0\r\n\r\n"
<- ""
OSSL_DEBUG: SSL SESSION new callback entered [ossl_ssl.c:454]
-> "HTTP/1.1 200 OK\r\n"
-> "Content-Length: 0\r\n"
-> "\r\n"
reading 0 bytes...
-> ""
read 0 bytes
Conn keep-alive
```

However, based on https://github.com/ruby/ruby/pull/1089#issuecomment-159878003 that change may not be correct. Or it could be that Ruby on Windows doesn't have this issue anymore.

---Files--------------------------------
Server.java (3.75 KB)
http.rb (423 Bytes)
ca.pem (8.43 KB)
certs.p12 (2.24 KB)


-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/


In This Thread

Prev Next