Bug #9954

Unexpected Hash Modification and Segmentation Fault with Named Arguments

Added by Ajedi32 (Andrew M) about 3 years ago. Updated about 3 years ago.

Target version:
ruby -v:
ruby 2.1.2p95 (2014-05-08 revision 45877) [i686-linux]


While experimenting with named arguments in Ruby 2.1.2, I encountered some strange behavior where a hash was modified after being passed as a set of named arguments with the double-splat operator. While attempting to examine the issue further, I encountered a segmentation fault which I believe to be related.

I have attached a log of my experiment, and a .rb file which reproduces both the unexpected hash modification and the segfault.

segfault.rb (1.2 KB) segfault.rb File which reproduces the problem Ajedi32 (Andrew M), 06/18/2014 04:32 PM
pry_sample_output.txt (35 KB) pry_sample_output.txt Sample output my console (with PRY) Ajedi32 (Andrew M), 06/18/2014 04:36 PM

Related issues

Is duplicate of Ruby trunk - Bug #9898: Keyword argument odditiesClosed2014-06-03

Associated revisions

Revision 46619
Added by nagachika (Tomoyuki Chikanaga) about 3 years ago

merge revision(s) r46342: [Backport #9954]

* vm.c (core_hash_merge_kwd): should return the result hash, which
  may be converted from and differ from the given argument.
   [Bug #9898]


#1 [ruby-core:63229] Updated by nobu (Nobuyoshi Nakada) about 3 years ago

  • Is duplicate of Bug #9898: Keyword argument oddities added

#2 [ruby-core:63230] Updated by nobu (Nobuyoshi Nakada) about 3 years ago

  • Status changed from Open to Closed
  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: DONTNEED, 2.1: REQUIRED

#3 [ruby-core:63232] Updated by Ajedi32 (Andrew M) about 3 years ago

Hmm... that doesn't really seem like the same issue (it has totally different symptoms from what I described here) but I'll trust your judgement on this one.

#4 [ruby-core:63235] Updated by nobu (Nobuyoshi Nakada) about 3 years ago

2.1.2p132 segfaults by your script, due to the access to the non-Hash object as a Hash object.
r46342 fixes it to return the converted result.

#5 [ruby-core:63410] Updated by nagachika (Tomoyuki Chikanaga) about 3 years ago

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

Backported into ruby_2_1 branch at r46619.

Also available in: Atom PDF