From 57d315c937e79199af2b77f21f5eecaca85ffac8 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Mon, 13 Sep 2021 11:59:04 -0700 Subject: Handle overwriting Object::ENV in spawn Instead of looking for Object::ENV (which can be overwritten), directly look for the envtbl variable. As that is static in hash.c, and the lookup code is in process.c, add a couple non-static functions that will return envtbl (or envtbl#to_hash). Fixes [Bug #18164] --- test/ruby/test_process.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 80d2eefca9..07aa58418b 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -261,6 +261,18 @@ class TestProcess < Test::Unit::TestCase } end + def test_overwrite_ENV + assert_separately([],"#{<<~"begin;"}\n#{<<~"end;"}") + BUG = "[ruby-core:105223] [Bug #18164]" + begin; + $VERBOSE = nil + ENV = {} + pid = spawn({}, *#{TRUECOMMAND.inspect}) + ENV.replace({}) + assert_kind_of(Integer, pid, BUG) + end; + end + MANDATORY_ENVS = %w[RUBYLIB MJIT_SEARCH_BUILD_DIR] case RbConfig::CONFIG['target_os'] when /linux/ -- cgit v1.2.3