Skip to content

Commit fd6d6a4

Browse files
committed
ZJIT: Use shellwords in bisect script
1 parent 0b30cf3 commit fd6d6a4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tool/zjit_bisect.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env ruby
22
require 'logger'
33
require 'open3'
4+
require 'shellwords'
45
require 'tempfile'
56
require 'timeout'
67

78
RUBY = ARGV[0] || raise("Usage: ruby jit_bisect.rb <path_to_ruby> <options>")
8-
OPTIONS = ARGV[1] || raise("Usage: ruby jit_bisect.rb <path_to_ruby> <options>")
9+
OPTIONS = ARGV[1..]
10+
raise("Usage: ruby jit_bisect.rb <path_to_ruby> -- <options>") if OPTIONS.empty?
911
TIMEOUT_SEC = 5
1012
LOGGER = Logger.new($stdout)
1113

@@ -65,7 +67,8 @@ def run_with_jit_list(ruby, options, jit_list)
6567
temp_file.flush
6668
temp_file.close
6769
# Run the JIT with the temporary file
68-
Open3.capture3("#{ruby} --zjit-allowed-iseqs=#{temp_file.path} #{options}")
70+
command = Shellwords.join [ruby, "--zjit-allowed-iseqs=#{temp_file.path}", *options]
71+
Open3.capture3(command)
6972
end
7073
end
7174

@@ -77,7 +80,8 @@ def run_with_jit_list(ruby, options, jit_list)
7780
# Collect the JIT list from the failing Ruby process
7881
jit_list = nil
7982
Tempfile.create "jit_list" do |temp_file|
80-
Open3.capture3("#{RUBY} --zjit-log-compiled-iseqs=#{temp_file.path} #{OPTIONS}")
83+
command = Shellwords.join [RUBY, "--zjit-log-compiled-iseqs=#{temp_file.path}", *OPTIONS]
84+
Open3.capture3(command)
8185
jit_list = File.readlines(temp_file.path).map(&:strip).reject(&:empty?)
8286
end
8387
LOGGER.info("Starting with JIT list of #{jit_list.length} items.")
@@ -94,6 +98,7 @@ def run_with_jit_list(ruby, options, jit_list)
9498
file.puts(result)
9599
end
96100
puts "Run:"
97-
puts "#{RUBY} --zjit-allowed-iseqs=jitlist.txt #{OPTIONS}"
101+
command = Shellwords.join [RUBY, "--zjit-allowed-iseqs=jitlist.txt", *OPTIONS]
102+
puts command
98103
puts "Reduced JIT list (available in jitlist.txt):"
99104
puts result

0 commit comments

Comments
 (0)