Actions
Bug #16041
closedeval's path argument seems to trigger GC bug
Description
$ pwd
/tmp/bug-0123456789
$ cat bug.rb
require "pathname"
file = "1.rb"
path = Pathname.new(file)
eval(File.read(file), nil, path.expand_path.to_s)
file2 = Dir["1.rb"].first
p file == file2 #=> true
path = Pathname.new(file2) # if it is Pathname.new(file), it works gracefully
eval(File.read(file), nil, path.expand_path.to_s)
$ cat 1.rb
require_relative '2'
__FILE__
$ cat 2.rb
$ ~/work/ruby/local/bin/ruby -v
ruby 2.7.0dev (2019-08-02T14:01:54Z master 247b06d400) [x86_64-linux]
$ ~/work/ruby/local/bin/ruby bug.rb
true
Traceback (most recent call last):
3: from bug.rb:10:in `<main>'
2: from bug.rb:10:in `eval'
1: from ��YmV:1:in `<main>'
��YmV:1:in `require_relative': path name contains null byte (ArgumentError)
As you see, the backtrace contains broken bytes.
Notes:
- If
Pathname.new(file2)
is replaced withPathname.new(file)
, it works without an error. Butfile == file2
evaluates to true. - The directory
/tmp/bug-0123456789
is important to reproduce the issue. If it is shorter, you cannot repro. I guess it is related to whether the path string is embedded or not. - This issue was originally caused in bundler.
@nobu (Nobuyoshi Nakada) @ko1 (Koichi Sasada) can you debug?
Actions
Like0
Like0Like0Like0Like0Like0