Skip to content

Conversation

luke-gruber
Copy link

No description provided.

if main_ractor?
assert_warn(/#{tlhInganHol}/) {
EnvUtil.with_default_internal(nil) {
open(IO::NULL, "w:bom|#{tlhInganHol}") {|f| enc = f.external_encoding}

Check failure

Code scanning / CodeQL

Use of `Kernel.open` or `IO.read` or similar sinks with a non-constant value Critical test

Call to Kernel.open with a non-constant value. Consider replacing it with File.open.

Copilot Autofix

AI 13 days ago

To fix the problem, replace the use of open (which refers to Kernel.open) with File.open for file operations. In this case, change open(IO::NULL, "w:bom|#{tlhInganHol}") to File.open(IO::NULL, "w:bom|#{tlhInganHol}"). This ensures that the file is opened safely, and the mode string is only interpreted as a file mode, not as a potential shell command. No additional imports or definitions are needed, as File is part of Ruby's core library. Only the flagged line (2308) needs to be changed.

Suggested changeset 1
test/ruby/test_io_m17n.rb

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -2305,7 +2305,7 @@
     if main_ractor?
       assert_warn(/#{tlhInganHol}/) {
         EnvUtil.with_default_internal(nil) {
-          open(IO::NULL, "w:bom|#{tlhInganHol}") {|f| enc = f.external_encoding}
+          File.open(IO::NULL, "w:bom|#{tlhInganHol}") {|f| enc = f.external_encoding}
         }
       }
       assert_nil(enc)
EOF
@@ -2305,7 +2305,7 @@
if main_ractor?
assert_warn(/#{tlhInganHol}/) {
EnvUtil.with_default_internal(nil) {
open(IO::NULL, "w:bom|#{tlhInganHol}") {|f| enc = f.external_encoding}
File.open(IO::NULL, "w:bom|#{tlhInganHol}") {|f| enc = f.external_encoding}
}
}
assert_nil(enc)
Copilot is powered by AI and may make mistakes. Always verify output.
assert_no_match(/Amiga/, line)
assert_no_match(/paper/, line)
if main_ractor?
tmp = open(tmpfilename, "r")

Check failure

Code scanning / CodeQL

Use of `Kernel.open` or `IO.read` or similar sinks with a non-constant value Critical test

Call to Kernel.open with a non-constant value. Consider replacing it with File.open.

Copilot Autofix

AI 13 days ago

The best way to fix this problem is to replace all instances of open(tmpfilename, ...) with File.open(tmpfilename, ...). This ensures that the file is opened directly, and Ruby will not interpret the filename as a shell command, even if it starts with a |. The change should be made in all places within the shown code where open is called with a variable filename. No additional imports or method definitions are needed, as File is part of Ruby's core library.

Suggested changeset 1
test/ruby/test_whileuntil.rb

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/test/ruby/test_whileuntil.rb b/test/ruby/test_whileuntil.rb
--- a/test/ruby/test_whileuntil.rb
+++ b/test/ruby/test_whileuntil.rb
@@ -7,7 +7,7 @@
     Dir.mktmpdir("ruby_while_tmp") {|tmpdir|
       tmpfilename = "#{tmpdir}/ruby_while_tmp.#{$$}"
 
-      tmp = open(tmpfilename, "w")
+      tmp = File.open(tmpfilename, "w")
       tmp.print "tvi925\n";
       tmp.print "tvi920\n";
       tmp.print "vt100\n";
@@ -15,7 +15,7 @@
       tmp.print "paper\n";
       tmp.close
 
-      tmp = open(tmpfilename, "r")
+      tmp = File.open(tmpfilename, "r")
       assert_instance_of(File, tmp)
 
       while line = tmp.gets()
@@ -26,7 +26,7 @@
       assert_match(/vt100/, line)
       tmp.close
 
-      tmp = open(tmpfilename, "r")
+      tmp = File.open(tmpfilename, "r")
       while line = tmp.gets()
         next if /vt100/ =~ line
         assert_no_match(/vt100/, line)
@@ -35,7 +35,7 @@
       assert_no_match(/vt100/, line)
       tmp.close
 
-      tmp = open(tmpfilename, "r")
+      tmp = File.open(tmpfilename, "r")
       while line = tmp.gets()
         lastline = line
         line = line.gsub(/vt100/, 'VT100')
@@ -60,7 +60,7 @@
       assert_equal(220, sum)
 
       if main_ractor?
-        tmp = open(tmpfilename, "r")
+        tmp = File.open(tmpfilename, "r")
         while line = tmp.gets()
           break if $. == 3
           assert_no_match(/vt100/, line)
EOF
@@ -7,7 +7,7 @@
Dir.mktmpdir("ruby_while_tmp") {|tmpdir|
tmpfilename = "#{tmpdir}/ruby_while_tmp.#{$$}"

tmp = open(tmpfilename, "w")
tmp = File.open(tmpfilename, "w")
tmp.print "tvi925\n";
tmp.print "tvi920\n";
tmp.print "vt100\n";
@@ -15,7 +15,7 @@
tmp.print "paper\n";
tmp.close

tmp = open(tmpfilename, "r")
tmp = File.open(tmpfilename, "r")
assert_instance_of(File, tmp)

while line = tmp.gets()
@@ -26,7 +26,7 @@
assert_match(/vt100/, line)
tmp.close

tmp = open(tmpfilename, "r")
tmp = File.open(tmpfilename, "r")
while line = tmp.gets()
next if /vt100/ =~ line
assert_no_match(/vt100/, line)
@@ -35,7 +35,7 @@
assert_no_match(/vt100/, line)
tmp.close

tmp = open(tmpfilename, "r")
tmp = File.open(tmpfilename, "r")
while line = tmp.gets()
lastline = line
line = line.gsub(/vt100/, 'VT100')
@@ -60,7 +60,7 @@
assert_equal(220, sum)

if main_ractor?
tmp = open(tmpfilename, "r")
tmp = File.open(tmpfilename, "r")
while line = tmp.gets()
break if $. == 3
assert_no_match(/vt100/, line)
Copilot is powered by AI and may make mistakes. Always verify output.
@luke-gruber luke-gruber force-pushed the test_all_ractors_multi_ractor branch from 4a3a2d7 to f3aa1ea Compare August 12, 2025 17:45
XrXr and others added 28 commits August 15, 2025 18:02
At under a minute, this check runs faster than a lot of the other CI
checks, so we might as well show errors from `cargo check` to serve as a
smoke check in addition to surfacing warnings.
On systems where the Encoding.default_internal defaults to US-ASCII instead
of UTF-8, some tests using assert_raise_with_message can fail since it no
longer changes Encoding.default_internal in 79f5202.

This tests explicitly uses EnvUtil.with_default_internal on systems where
these tests fail.
The VPATH rule of NMake is different from others.  Abandon using
them in the rules for the generated source, locate them in the top
source directory, as well as the generated library files of prism.
The current oldest support Ruby version is 3.2. And Ruby 3.2 bundled
Bundler 2.5. It means RG 4.0 can drop to support Bundler 2.2.

rubygems/rubygems@592ac09b5c
…ation warning

Like others, it's a remembered option which we are deprecating in favor
of configuration.

rubygems/rubygems@9ea55e0df2
The `bundle list` command is a convenient way for human to know what gems and versions are available. By introducing a `--format=json` option, we can provide the same information to machines in a stable format that is robust to UI additions or modifications. It indirectly supports  `Gemfile.lock` modifications by discouraging external tools from attempting to parse that format.

This addition allows for the scripting of installation tools, such as buildpacks, that wish to branch logic based on gem versions. For example:

```ruby
require "json"

command = "bundle list --format=json"
output = `#{command}`
raise "Command `#{command}` errored: #{output}" unless $?.success?

railties = JSON.parse(output).find {|gem| gem["name"] == railties }
if railties && Gem::Version.new(railties["version"]) >= Gem::Version.new("7")
  puts "Using Rails greater than 7!"
end
```

The top level is an object with a single key, "gems", this structure allows us to add other information in the future (should we desire) without having to change the json schema.

rubygems/rubygems@9e081b0689
…st in a specific case

If upgrading `foo` needs an indirect dependency to be downgraded,
Bundler would not be able to upgrade foo.

This is because when calculating the latest resolvable version of foo,
Bundler was still adding lower bound requirements on the locked versions
of all dependencies to avoid downgrades, effectively pinning foo to a
version older than the latest.

To fix this, instead of creating a second "unlocked" definition to
figure out the latest resolvable version, create a second unlocked
resolver, and DO NOT add lower bound requirements to it.

rubygems/rubygems@00cc0ecc69
deivid-rodriguez and others added 28 commits August 18, 2025 12:31
Name default value placeholders in a more standard way. That's what our
specs check, but they don't yet work for subcommand flags.

rubygems/rubygems@c589899cb8
Make synopsis, subcommands, and CLI flags use a format consistent with
the other docs, and also reword some sentences for clarify.

rubygems/rubygems@9272169ad0
To save some unnecessary `bundle install` commands.

rubygems/rubygems@61e7d9d09a
We had them duplicated, but with slightly different features:

* The ones in `other/cli_man_pages.rb` enforced a specific structure to
  document CLI options, so were less likely to have false positives.

* The ones in `quality_spec.rb` were able to check subcommands and their
  flags.

This commit merges both and preserves the best of both.
Since we handle embedded arrays in the if statement above, we don't need
to handle it here.
This tests for ractor safety issues as well as issues with GC and the
ractor scheduler. It also tests move/copy logic because it uses these
internally for running the tests.

You can enable these tests with RUBY_TESTS_WITH_RACTORS=1 when running
`make test-all TESTS=test/ruby`. These ractor tests are currently only
working for tests under the "test/ruby" directory, so don't run any
others with this ENV var set or you will get errors.

Currently there are GC issues with ractors so in tool/lib/test/unit.rb, I disable the
GC before running any of the tests (for now). If you uncomment this, you will get
errors and you can debug the GC issues.
Without a VM Lock, there's an unlocked `rb_id_table_delete` for the
class's const_tbl which can cause problems. Example:

```ruby
class C
  CONSTANT = 3
end
$VERBOSE = nil
rs = []
100.times do
  rs << Ractor.new do
    10_000.times do
      if defined?(C::CONSTANT)
        C.send(:remove_const, :CONSTANT) rescue NameError
      else
        C.send(:const_set, :CONSTANT, 3)
      end
    end
  end
end
while rs.any?
  r, obj = Ractor.select(*rs)
  rs.delete(r)
end
```

Without lock:
../ruby-release/test.rb:14: [BUG] Segmentation fault at 0x0000000000000001
-- Control frame information -----------------------------------------------
miniruby(82790,0x16f49f000) malloc: *** error for object 0x600000f880a0: pointer being freed was not allocated
miniruby(82790,0x16f49f000) malloc: *** set a breakpoint in malloc_error_break to debug
@peterzhu2118 peterzhu2118 force-pushed the test_all_ractors_multi_ractor branch from 88d6f7b to 8048328 Compare August 18, 2025 13:51
It prevents a string from being used for `encoding`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.