summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2023-07-22 13:03:22 +0900
committernagachika <nagachika@ruby-lang.org>2023-07-22 13:03:22 +0900
commitea89527a76a84741463c304246db2dd3a5df845b (patch)
treee211be19a5741aef1a466a23037de21df9487d06 /test
parent465eb7418d7ed91f5f0c75da77765c7f5ef8354f (diff)
merge revision(s) 0b2613f44309bddae45562c9f3a14ed43e56959b: [Backport #19640]
`rb_io_puts` should not write zero length strings. (#7806) --- io.c | 40 ++++++++++++++++++++++++---------------- test/fiber/test_io.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 16 deletions(-)
Diffstat (limited to 'test')
-rw-r--r--test/fiber/test_io.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/fiber/test_io.rb b/test/fiber/test_io.rb
index de88745e57..c1ad56a8cf 100644
--- a/test/fiber/test_io.rb
+++ b/test/fiber/test_io.rb
@@ -170,6 +170,34 @@ class TestFiberIO < Test::Unit::TestCase
assert_predicate(o, :closed?)
end
+ def test_puts_empty
+ omit "UNIXSocket is not defined!" unless defined?(UNIXSocket)
+
+ i, o = UNIXSocket.pair
+ i.nonblock = false
+ o.nonblock = false
+
+ thread = Thread.new do
+ # This scheduler provides non-blocking `io_read`/`io_write`:
+ scheduler = IOBufferScheduler.new
+ Fiber.set_scheduler scheduler
+
+ Fiber.schedule do
+ # This was causing a segfault on older Ruby.
+ o.puts ""
+ o.puts nil
+ o.close
+ end
+ end
+
+ thread.join
+
+ message = i.read
+ i.close
+
+ assert_equal $/*2, message
+ end
+
def test_io_select
omit "UNIXSocket is not defined!" unless defined?(UNIXSocket)