ruby-changes:44179
From: rhe <ko1@a...>
Date: Mon, 26 Sep 2016 15:43:57 +0900 (JST)
Subject: [ruby-changes:44179] rhe:r56252 (trunk): eval_intern.h: make TH_PUSH_TAG() initialize rb_vm_tag::tag with Qundef
rhe 2016-09-26 15:43:51 +0900 (Mon, 26 Sep 2016) New Revision: 56252 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56252 Log: 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. Modified files: trunk/ChangeLog trunk/eval_intern.h trunk/test/ruby/test_exception.rb Index: test/ruby/test_exception.rb =================================================================== --- test/ruby/test_exception.rb (revision 56251) +++ test/ruby/test_exception.rb (revision 56252) @@ -181,6 +181,15 @@ class TestException < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L181 } 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) Index: eval_intern.h =================================================================== --- eval_intern.h (revision 56251) +++ eval_intern.h (revision 56252) @@ -131,7 +131,7 @@ LONG WINAPI rb_w32_stack_overflow_handle https://github.com/ruby/ruby/blob/trunk/eval_intern.h#L131 #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() \ Index: ChangeLog =================================================================== --- ChangeLog (revision 56251) +++ ChangeLog (revision 56252) @@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Sep 26 15:43:34 2016 Kazuki Yamaguchi <k@r...> + + * 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 <sonots@g...> * lib/tempfile.rb: provide default basename parameter for -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/