From ed5a926b1320983e6802d17d6bc7c2d6c3f52989 Mon Sep 17 00:00:00 2001 From: rhe Date: Mon, 26 Sep 2016 06:43:51 +0000 Subject: [PATCH] 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 --- ChangeLog | 11 +++++++++++ eval_intern.h | 2 +- test/ruby/test_exception.rb | 9 +++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5ad1105e52..a39f2dc505 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Mon Sep 26 15:43:34 2016 Kazuki Yamaguchi + + * 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. + Mon Sep 26 14:36:12 2016 Naotoshi Seo * lib/tempfile.rb: provide default basename parameter for diff --git a/eval_intern.h b/eval_intern.h index 9db0fd1bdb..c5210b14de 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -131,7 +131,7 @@ LONG WINAPI rb_w32_stack_overflow_handler(struct _EXCEPTION_POINTERS *); #define TH_PUSH_TAG(th) do { \ rb_thread_t * const _th = (th); \ struct rb_vm_tag _tag; \ - _tag.tag = 0; \ + _tag.tag = Qundef; \ _tag.prev = _th->tag; #define TH_POP_TAG() \ diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 10489dd5ba..4da3de165b 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -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)