New Upstream Release - ruby-posix-spawn

Ready changes

Summary

Merged new upstream version: 0.3.15 (was: 0.3.13).

Resulting package

Built on 2022-11-24T09:43 (took 2m48s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-releases ruby-posix-spawn-dbgsymapt install -t fresh-releases ruby-posix-spawn

Lintian Result

Diff

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4633a7f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+Gemfile.lock
+ext/Makefile
+lib/posix_spawn_ext.*
+tmp
+pkg
+.bundle
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..a56fc80
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,9 @@
+sudo: false
+language: ruby
+rvm:
+  - 1.9
+  - 2.0
+  - 2.2
+  - 2.4
+  - 2.6
+  - ruby-head
diff --git a/bin/posix-spawn-benchmark b/bin/posix-spawn-benchmark
index 5ef90eb..71d0b01 100755
--- a/bin/posix-spawn-benchmark
+++ b/bin/posix-spawn-benchmark
@@ -1,17 +1,117 @@
 #!/usr/bin/env ruby
-# frozen_string_literal: true
-#
-# This file was generated by Bundler.
-#
-# The application 'posix-spawn-benchmark' is installed as part of a gem, and
-# this file is here to facilitate running it.
-#
-
-require "pathname"
-ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
-  Pathname.new(__FILE__).realpath)
-
-require "rubygems"
-require "bundler/setup"
-
-load Gem.bin_path("posix-spawn", "posix-spawn-benchmark")
+#/ Usage: posix-spawn-benchmark [-n <count>] [-m <mem-size>]
+#/ Run posix-spawn (Ruby extension) benchmarks and report to standard output.
+#/
+#/ Options:
+#/   -n, --count=NUM         total number of processes to spawn.
+#/   -m, --mem-size=MB       RES size to bloat to before performing benchmarks.
+#/   -g, --graph             benchmark at 10MB itervals up to RES and graph results.
+#/
+#/ Benchmarks run with -n 1000 -m 100 by default.
+require 'optparse'
+require 'posix-spawn'
+require 'benchmark'
+include Benchmark
+
+allocate   = 100 * (1024 ** 2)
+iterations = 1_000
+graphmode  = false
+ARGV.options do |o|
+  o.set_summary_indent('  ')
+  o.on("-n", "--count=num")   { |val| iterations = val.to_i }
+  o.on("-m", "--mem-size=MB") { |val| allocate   = val.to_i * (1024 ** 2) }
+  o.on("-g", "--graph")       { graphmode = true }
+  o.on_tail("-h", "--help")   { exec "grep ^#/ <'#{__FILE__}' |cut -c4-" }
+  o.parse!
+end
+
+if graphmode
+  bloat = []
+  data  = {}
+  chunk = allocate / 10
+  max   = 0
+
+  10.times do
+    puts "allocating #{chunk / (1024 ** 2)}MB (#{(bloat.size+1) * chunk / (1024 ** 2)}MB total)"
+    bloat << ('x' * chunk)
+    # size = bloat.size / (1024 ** 2)
+
+    %w[ fspawn pspawn ].each do |type|
+      print " - benchmarking #{type}... "
+      time = Benchmark.realtime do
+        iterations.times do
+          pid = POSIX::Spawn.send(type, 'true')
+          Process.wait(pid)
+        end
+      end
+      puts "done (#{time})"
+
+      data[type] ||= []
+      data[type] << time
+      max = time if time > max
+    end
+  end
+
+  max = max < 0.5 ? (max * 10).round / 10.0 : max.ceil
+  minmb, maxmb = chunk/(1024**2), allocate/(1024**2)
+  series = %w[ fspawn pspawn ].map{|name| data[name].map{|d| "%.2f" % d }.join(',') }
+
+  chart = {
+    :chs  => '900x200',
+    :cht  => 'bvg', # grouped vertical bar chart
+    :chtt => "posix-spawn-benchmark --graph --count #{iterations} --mem-size #{maxmb} (#{RUBY_PLATFORM})",
+
+    :chf  => 'bg,s,f8f8f8', # background
+    :chbh => 'a,5,25', # 25px between bar groups
+
+    :chd  => "t:#{series.join('|')}", # data
+    :chds => "0,#{max}", # scale
+    :chdl => 'fspawn (fork+exec)|pspawn (posix_spawn)', # legend
+    :chco => '1f77b4,ff7f0e', # colors
+
+    :chxt => 'x,y',
+    :chxr => "1,0,#{max},#{max/5}", # y labels up to max time
+    :chxs => '1N** secs', # y labels are +=' secs'
+    :chxl => "0:|#{minmb.step(maxmb, maxmb/10).map{ |mb| "#{mb} MB"}.join('|')}", # x bucket labels
+  }
+
+  url  = "https://chart.googleapis.com/chart?"
+  url += chart.map do |key, val|
+    "#{key}=#{val.gsub(' ','%20').gsub('(','%28').gsub(')','%29').gsub('+','%2B')}"
+  end.join('&')
+  url += '#.png'
+
+  puts url
+
+  exit!
+end
+
+puts "benchmarking fork/exec vs. posix_spawn over #{iterations} runs" +
+     " at #{allocate / (1024 ** 2)}M res"
+
+# bloat the process
+bloat = 'x' * allocate
+
+# run the benchmarks
+bm 40 do |x|
+  x.report("fspawn (fork/exec):") do
+    iterations.times do
+      pid = POSIX::Spawn.fspawn('true')
+      Process.wait(pid)
+    end
+  end
+  x.report("pspawn (posix_spawn):") do
+    iterations.times do
+      pid = POSIX::Spawn.pspawn('true')
+      Process.wait(pid)
+    end
+  end
+  if Process.respond_to?(:spawn)
+    x.report("spawn (native):") do
+      iterations.times do
+        pid = Process.spawn('true')
+        Process.wait(pid)
+      end
+    end
+  end
+end
diff --git a/debian/changelog b/debian/changelog
index f377a8e..d90fc49 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,11 +1,13 @@
-ruby-posix-spawn (0.3.13-4) UNRELEASED; urgency=medium
+ruby-posix-spawn (0.3.15-1) UNRELEASED; urgency=medium
 
   * Update watch file format version to 4.
   * Bump debhelper from old 12 to 13.
   * Update standards version to 4.5.1, no changes needed.
   * Update standards version to 4.6.1, no changes needed.
+  * New upstream release.
+  * Drop patch 5201e921a788fbb97f14ea0c617a2213dc3da1ca.patch, present upstream.
 
- -- Debian Janitor <janitor@jelmer.uk>  Sun, 29 Aug 2021 14:52:44 -0000
+ -- Debian Janitor <janitor@jelmer.uk>  Thu, 24 Nov 2022 09:41:13 -0000
 
 ruby-posix-spawn (0.3.13-3) unstable; urgency=medium
 
diff --git a/debian/patches/0001-Avoid-using-PATH_MAX-for-GNU-Hurd.patch b/debian/patches/0001-Avoid-using-PATH_MAX-for-GNU-Hurd.patch
index 068ead2..2eea170 100644
--- a/debian/patches/0001-Avoid-using-PATH_MAX-for-GNU-Hurd.patch
+++ b/debian/patches/0001-Avoid-using-PATH_MAX-for-GNU-Hurd.patch
@@ -7,11 +7,11 @@ Signed-off-by: Youhei SASAKI <uwabami@gfd-dennou.org>
  ext/posix-spawn.c | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
 
-diff --git a/ext/posix-spawn.c b/ext/posix-spawn.c
-index 1659bed..5f3587a 100644
---- a/ext/posix-spawn.c
-+++ b/ext/posix-spawn.c
-@@ -462,8 +462,12 @@ rb_posixspawn_pspawn(VALUE self, VALUE env, VALUE argv, VALUE options)
+Index: ruby-posix-spawn.git/ext/posix-spawn.c
+===================================================================
+--- ruby-posix-spawn.git.orig/ext/posix-spawn.c
++++ ruby-posix-spawn.git/ext/posix-spawn.c
+@@ -467,8 +467,12 @@ rb_posixspawn_pspawn(VALUE self, VALUE e
  	}
  
  	if (ret != 0) {
diff --git a/debian/patches/0002-Remove-git-ls-files-from-gemspec.patch b/debian/patches/0002-Remove-git-ls-files-from-gemspec.patch
index c29fe63..ad230d8 100644
--- a/debian/patches/0002-Remove-git-ls-files-from-gemspec.patch
+++ b/debian/patches/0002-Remove-git-ls-files-from-gemspec.patch
@@ -7,10 +7,10 @@ Signed-off-by: Youhei SASAKI <uwabami@gfd-dennou.org>
  posix-spawn.gemspec | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
-diff --git a/posix-spawn.gemspec b/posix-spawn.gemspec
-index 532e5f7..5df9340 100644
---- a/posix-spawn.gemspec
-+++ b/posix-spawn.gemspec
+Index: ruby-posix-spawn.git/posix-spawn.gemspec
+===================================================================
+--- ruby-posix-spawn.git.orig/posix-spawn.gemspec
++++ ruby-posix-spawn.git/posix-spawn.gemspec
 @@ -20,6 +20,6 @@ Gem::Specification.new do |s|
    s.executables << 'posix-spawn-benchmark'
    s.require_paths = ['lib']
diff --git a/debian/patches/5201e921a788fbb97f14ea0c617a2213dc3da1ca.patch b/debian/patches/5201e921a788fbb97f14ea0c617a2213dc3da1ca.patch
deleted file mode 100644
index b96579b..0000000
--- a/debian/patches/5201e921a788fbb97f14ea0c617a2213dc3da1ca.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From 5201e921a788fbb97f14ea0c617a2213dc3da1ca Mon Sep 17 00:00:00 2001
-From: Pascal Terjan <pterjan@google.com>
-Date: Sun, 20 Aug 2017 12:13:15 +0100
-Subject: [PATCH] Fix build when SIZEOF_INT == SIZEOF_LONG
-
-Signed-off-by: Aman Gupta <aman@tmm1.net>
----
- ext/posix-spawn.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/ext/posix-spawn.c b/ext/posix-spawn.c
-index 1659bed..2e4c4de 100644
---- a/ext/posix-spawn.c
-+++ b/ext/posix-spawn.c
-@@ -61,7 +61,7 @@ posixspawn_obj_to_fd(VALUE obj)
- 			 * rb_fix2int takes care of raising if the provided object is a
- 			 * Bignum and is out of range of an int
- 			 */
--			fd = (int)rb_fix2int(obj);
-+			fd = FIX2INT(obj);
- 			break;
- 
- 		case T_SYMBOL:
diff --git a/debian/patches/series b/debian/patches/series
index fc2359d..426aaa6 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,2 @@
 0001-Avoid-using-PATH_MAX-for-GNU-Hurd.patch
 0002-Remove-git-ls-files-from-gemspec.patch
-5201e921a788fbb97f14ea0c617a2213dc3da1ca.patch
diff --git a/ext/posix-spawn.c b/ext/posix-spawn.c
index 1659bed..7ff2464 100644
--- a/ext/posix-spawn.c
+++ b/ext/posix-spawn.c
@@ -61,7 +61,7 @@ posixspawn_obj_to_fd(VALUE obj)
 			 * rb_fix2int takes care of raising if the provided object is a
 			 * Bignum and is out of range of an int
 			 */
-			fd = (int)rb_fix2int(obj);
+			fd = FIX2INT(obj);
 			break;
 
 		case T_SYMBOL:
@@ -283,6 +283,11 @@ each_env_i(VALUE key, VALUE val, VALUE arg)
 		const char *ev = envp[i];
 
 		if (strlen(ev) > name_len && !memcmp(ev, name, name_len) && ev[name_len] == '=') {
+			/* This operates on a duplicated environment -- release the
+			 * existing entry memory before shifting the subsequent entry
+			 * pointers down. */
+			free(envp[i]);
+
 			for (j = i; envp[j]; ++j)
 				envp[j] = envp[j + 1];
 			continue;
diff --git a/lib/posix/spawn.rb b/lib/posix/spawn.rb
index b8ad25b..6dcbbe6 100644
--- a/lib/posix/spawn.rb
+++ b/lib/posix/spawn.rb
@@ -529,7 +529,7 @@ module POSIX
     #
     # Returns a [[cmdname, argv0], argv1, ...] array.
     def adjust_process_spawn_argv(args)
-      if args.size == 1 && args[0] =~ /[ |>]/
+      if args.size == 1 && args[0].is_a?(String) && args[0] =~ /[ |>]/
         # single string with these characters means run it through the shell
         command_and_args = system_command_prefixes + [args[0]]
         [*command_and_args]
diff --git a/lib/posix/spawn/child.rb b/lib/posix/spawn/child.rb
index 98e3ae2..50d98ff 100644
--- a/lib/posix/spawn/child.rb
+++ b/lib/posix/spawn/child.rb
@@ -1,5 +1,3 @@
-require 'posix/spawn'
-
 module POSIX
   module Spawn
     # POSIX::Spawn::Child includes logic for executing child processes and
diff --git a/lib/posix/spawn/version.rb b/lib/posix/spawn/version.rb
index d79af0d..eb876c9 100644
--- a/lib/posix/spawn/version.rb
+++ b/lib/posix/spawn/version.rb
@@ -1,5 +1,5 @@
 module POSIX
   module Spawn
-    VERSION = '0.3.13'
+    VERSION = '0.3.15'
   end
 end
diff --git a/test/test_spawn.rb b/test/test_spawn.rb
index 486554f..f4038bc 100644
--- a/test/test_spawn.rb
+++ b/test/test_spawn.rb
@@ -322,7 +322,7 @@ module SpawnImplementationTests
       end
     end
 
-    assert_match /oops/, exception.message
+    assert_match(/oops/, exception.message)
   end
 
   ##

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in second set of .debs but not in first

-rw-r--r--  root/root   /usr/lib/debug/.build-id/87/ee92f9d7c11c7b82372e6bd09feae0a6c39278.debug
-rw-r--r--  root/root   /usr/lib/debug/.build-id/d1/ab57cb469e0ce10d0c11a7761086ca7b19033c.debug
-rw-r--r--  root/root   /usr/lib/debug/.dwz/x86_64-linux-gnu/ruby-posix-spawn.debug
-rw-r--r--  root/root   /usr/lib/x86_64-linux-gnu/ruby/vendor_ruby/3.0.0/posix_spawn_ext.so
-rw-r--r--  root/root   /usr/share/rubygems-integration/3.0.0/specifications/posix-spawn-0.3.15.gemspec
-rw-r--r--  root/root   /usr/share/rubygems-integration/3.1.0/specifications/posix-spawn-0.3.15.gemspec

Files in first set of .debs but not in second

-rw-r--r--  root/root   /usr/lib/debug/.build-id/8d/1f888a7bd8b28bb65c98cf8fe273ca3b4ffc9f.debug
-rw-r--r--  root/root   /usr/share/rubygems-integration/3.1.0/specifications/posix-spawn-0.3.13.gemspec

Control files of package ruby-posix-spawn: lines which differ (wdiff format)

  • Depends: ruby | ruby-interpreter, libc6 (>= 2.15), libruby3.0 (>= 3.0.0~preview1) | libruby3.1 (>= 3.1.2), libruby (>= 1:3.0~0) | libruby (>= 1:3.1~0), libruby (<< 1:3.2~)
  • Ruby-Versions: ruby3.0 ruby3.1

Control files of package ruby-posix-spawn-dbgsym: lines which differ (wdiff format)

  • Build-Ids: 8d1f888a7bd8b28bb65c98cf8fe273ca3b4ffc9f 87ee92f9d7c11c7b82372e6bd09feae0a6c39278 d1ab57cb469e0ce10d0c11a7761086ca7b19033c
  • Ruby-Versions: ruby3.0 ruby3.1

More details

Full run details