Project

General

Profile

Bug #10831

Variable keyword arguments shouldn't create immortal symbols

Added by marcandre (Marc-Andre Lafortune) about 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:68031]

Description

Calling a method with keyword arguments will, sometimes, create immortal symbols.

The following tests should not fail:

def test_kwarg_symbol_leak_no_rest
  foo = -> (arg: 42) {}
  assert_no_immortal_symbol_created("kwarg no rest") do |name|
    assert_raise(ArgumentError) { foo.call(name.to_sym => 42) }
  end
end

def test_kwarg_symbol_leak_with_rest
  foo = -> (arg: 2, **options) {}
  assert_no_immortal_symbol_created("kwarg with rest") do |name|
    foo.call(name.to_sym => 42)
  end
end

def test_kwarg_symbol_leak_just_rest
  foo = -> (**options) {}
  assert_no_immortal_symbol_created("kwarg just rest") do |name|
    foo.call(name.to_sym => 42)
  end
end

Note: the last one succeeds (because the hash is simply cloned internally), and is there for completeness.

Associated revisions

Revision b4f61ad6
Added by nobu (Nobuyoshi Nakada) about 4 years ago

vm_core.h: fix symbols leak

  • vm_core.h (rb_call_info_kw_arg_struct): make keywords a symbols list to get rid of inadvertent creation by variable keyword arguments. [ruby-core:68031] [Bug #10831]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 49517
Added by nobu (Nobuyoshi Nakada) about 4 years ago

vm_core.h: fix symbols leak

  • vm_core.h (rb_call_info_kw_arg_struct): make keywords a symbols list to get rid of inadvertent creation by variable keyword arguments. [ruby-core:68031] [Bug #10831]

Revision 49517
Added by nobu (Nobuyoshi Nakada) about 4 years ago

vm_core.h: fix symbols leak

  • vm_core.h (rb_call_info_kw_arg_struct): make keywords a symbols list to get rid of inadvertent creation by variable keyword arguments. [ruby-core:68031] [Bug #10831]

Revision 49517
Added by nobu (Nobuyoshi Nakada) about 4 years ago

vm_core.h: fix symbols leak

  • vm_core.h (rb_call_info_kw_arg_struct): make keywords a symbols list to get rid of inadvertent creation by variable keyword arguments. [ruby-core:68031] [Bug #10831]

Revision 49517
Added by nobu (Nobuyoshi Nakada) about 4 years ago

vm_core.h: fix symbols leak

  • vm_core.h (rb_call_info_kw_arg_struct): make keywords a symbols list to get rid of inadvertent creation by variable keyword arguments. [ruby-core:68031] [Bug #10831]

Revision 49517
Added by nobu (Nobuyoshi Nakada) about 4 years ago

vm_core.h: fix symbols leak

  • vm_core.h (rb_call_info_kw_arg_struct): make keywords a symbols list to get rid of inadvertent creation by variable keyword arguments. [ruby-core:68031] [Bug #10831]

Revision 81c37840
Added by naruse (Yui NARUSE) almost 4 years ago

merge revision(s) 49517: [Backport #10831]

* vm_core.h (rb_call_info_kw_arg_struct): make keywords a symbols
  list to get rid of inadvertent creation by variable keyword
  arguments.  [ruby-core:68031] [Bug #10831]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@49666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 49666
Added by naruse (Yui NARUSE) almost 4 years ago

merge revision(s) 49517: [Backport #10831]

* vm_core.h (rb_call_info_kw_arg_struct): make keywords a symbols
  list to get rid of inadvertent creation by variable keyword
  arguments.  [ruby-core:68031] [Bug #10831]

Revision 011347e4
Added by normal over 3 years ago

iseq.c (iseq_data_to_ary): dump kw_arg as symbol

Fix RubyVM::InstructionSequence#to_a after r49517
Keywords were made symbols to fix [Bug #10831] [ruby-core:68031],
so we should dump symbols as-is instead of attempting to convert
them from IDs

  • iseq.c (iseq_data_to_ary): dump kw_arg as symbol
  • test/-ext-/iseq_load/test_iseq_load.rb: test kw_arg roundtrip [ruby-core:69891] [Bug #11338]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 51190
Added by normalperson (Eric Wong) over 3 years ago

iseq.c (iseq_data_to_ary): dump kw_arg as symbol

Fix RubyVM::InstructionSequence#to_a after r49517
Keywords were made symbols to fix [Bug #10831] [ruby-core:68031],
so we should dump symbols as-is instead of attempting to convert
them from IDs

  • iseq.c (iseq_data_to_ary): dump kw_arg as symbol
  • test/-ext-/iseq_load/test_iseq_load.rb: test kw_arg roundtrip [ruby-core:69891] [Bug #11338]

Revision 51190
Added by normal over 3 years ago

iseq.c (iseq_data_to_ary): dump kw_arg as symbol

Fix RubyVM::InstructionSequence#to_a after r49517
Keywords were made symbols to fix [Bug #10831] [ruby-core:68031],
so we should dump symbols as-is instead of attempting to convert
them from IDs

  • iseq.c (iseq_data_to_ary): dump kw_arg as symbol
  • test/-ext-/iseq_load/test_iseq_load.rb: test kw_arg roundtrip [ruby-core:69891] [Bug #11338]

Revision 51190
Added by normal over 3 years ago

iseq.c (iseq_data_to_ary): dump kw_arg as symbol

Fix RubyVM::InstructionSequence#to_a after r49517
Keywords were made symbols to fix [Bug #10831] [ruby-core:68031],
so we should dump symbols as-is instead of attempting to convert
them from IDs

  • iseq.c (iseq_data_to_ary): dump kw_arg as symbol
  • test/-ext-/iseq_load/test_iseq_load.rb: test kw_arg roundtrip [ruby-core:69891] [Bug #11338]

Revision 51190
Added by normal over 3 years ago

iseq.c (iseq_data_to_ary): dump kw_arg as symbol

Fix RubyVM::InstructionSequence#to_a after r49517
Keywords were made symbols to fix [Bug #10831] [ruby-core:68031],
so we should dump symbols as-is instead of attempting to convert
them from IDs

  • iseq.c (iseq_data_to_ary): dump kw_arg as symbol
  • test/-ext-/iseq_load/test_iseq_load.rb: test kw_arg roundtrip [ruby-core:69891] [Bug #11338]

Revision 51190
Added by normal over 3 years ago

iseq.c (iseq_data_to_ary): dump kw_arg as symbol

Fix RubyVM::InstructionSequence#to_a after r49517
Keywords were made symbols to fix [Bug #10831] [ruby-core:68031],
so we should dump symbols as-is instead of attempting to convert
them from IDs

  • iseq.c (iseq_data_to_ary): dump kw_arg as symbol
  • test/-ext-/iseq_load/test_iseq_load.rb: test kw_arg roundtrip [ruby-core:69891] [Bug #11338]

History

#1

Updated by nobu (Nobuyoshi Nakada) about 4 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r49517.


vm_core.h: fix symbols leak

  • vm_core.h (rb_call_info_kw_arg_struct): make keywords a symbols list to get rid of inadvertent creation by variable keyword arguments. [ruby-core:68031] [Bug #10831]

Updated by naruse (Yui NARUSE) almost 4 years ago

  • Backport changed from 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: REQUIRED to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONE

ruby_2_2 r49666 merged revision(s) 49517.

Also available in: Atom PDF