Project

General

Profile

Bug #11594

A Proc call may corrupt a local variable

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

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-10-15 master 52128) [x86_64-linux]
[ruby-core:71088]

Description

x, y, z = 1, 2, 3
p [x, y, z] #=> [1, 2, 3] 
-> &blk { }.call &:foo
p [x, y, z] #=> [false, 2, 3] !!! WRONG !!!

The proc call in Line 3 modifies a local variable.

git bisect showed r52056. I confirmed it worked fine when I revert the commit.

  • rb_sym_to_proc creates a Proc instance,
  • rb_sym_to_proc calls rb_block_clear_env_self, and
  • rb_block_clear_env_self seems to break the variable, instead of clearing self.

I guess rb_sym_to_proc creates an inconsistent Proc, but I don't know what is happening precisely.

--
Yusuke Endoh mame@ruby-lang.org


Related issues

Related to Ruby master - Bug #11596: Getting [BUG] rb_vm_get_cref: unreachableClosedko1 (Koichi Sasada)Actions
#1

Updated by nobu (Nobuyoshi Nakada) about 5 years ago

  • Status changed from Assigned to Closed

Applied in changeset r52129.


proc.c: proc without env

  • proc.c (rb_sym_to_proc): move from string.c and create a Proc with no environments. [ruby-core:71088] [Bug #11594]
#2

Updated by wanabe (_ wanabe) about 5 years ago

  • Related to Bug #11596: Getting [BUG] rb_vm_get_cref: unreachable added

Also available in: Atom PDF