eval_intern.h: make TH_PUSH_TAG() initialize rb_vm_tag::tag with Qundef

* eval_intern.h (TH_PUSH_TAG): Initialize struct rb_vm_tag::tag with
  Qundef rather than 0 which is equal to Qfalse. Since Kernel#throw(obj)
  searches a tag with rb_vm_tag::tag == obj, throw(false) can
  accidentally find an unrelated tag which is not created by
  Kernel#catch.  [ruby-core:77229] [Bug #12743]

* test/ruby/test_exception.rb (test_throw_false): Add a test case for
  this.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
rhe 2016-09-26 06:43:51 +00:00
parent 64f53f0dbf
commit ed5a926b13
3 changed files with 21 additions and 1 deletions

View file

@ -181,6 +181,15 @@ class TestException < Test::Unit::TestCase
}
end
def test_throw_false
bug12743 = '[ruby-core:77229] [Bug #12743]'
assert_raise_with_message(UncaughtThrowError, /false/, bug12743) {
Thread.start {
throw false
}.join
}
end
def test_else_no_exception
begin
assert(true)