Project

General

Profile

Actions

Bug #16041

closed

eval's path argument seems to trigger GC bug

Added by mame (Yusuke Endoh) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Target version:
-
ruby -v:
[ruby-core:94122]

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 with Pathname.new(file), it works without an error. But file == 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?


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #15916: Memory leak in Regexp literal interpolationClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0