Project

General

Profile

0001-hash.c-any_hash-make-static-symbol-hash-non-determin.patch

normalperson (Eric Wong), 03/28/2017 05:00 PM

View differences:

hash.c
139 139
	if (a == Qundef) return 0;
140 140
	if (STATIC_SYM_P(a)) {
141 141
	    hnum = a >> (RUBY_SPECIAL_SHIFT + ID_SCOPE_SHIFT);
142
	    hnum = rb_hash_start(hnum);
142 143
	    goto out;
143 144
	}
144 145
	else if (FLONUM_P(a)) {
test/ruby/test_symbol.rb
411 411
    assert_equal str, str.to_sym.to_s
412 412
    assert_not_predicate(str, :frozen?, bug11721)
413 413
  end
414

  
415
  def test_hash_nondeterministic
416
    ruby = EnvUtil.rubybin
417
    refute_equal `#{ruby} -e 'puts :foo.hash'`, `#{ruby} -e 'puts :foo.hash'`,
418
                 '[ruby-core:80430] [Bug #13376]'
419

  
420
    sym = "dynsym_#{Random.rand(10000)}_#{Time.now}"
421
    refute_equal `#{ruby} -e 'puts #{sym.inspect}.to_sym.hash'`,
422
                 `#{ruby} -e 'puts #{sym.inspect}.to_sym.hash'`
423
  end
414 424
end
415
-