aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-09-09 23:23:14 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-09-11 02:09:23 +0900
commit274113311883bf395d4970da97bd6b597eae705e (patch)
treeabaa6250bfad7a041ac329e75c1160259a037dc9
parent3bb183188d5ee8adee9ac36f7983853dc2f1a836 (diff)
downloadruby-topic/fix-throw-false.tar.gz
eval_intern.h: make TH_PUSH_TAG() initialize rb_vm_tag::tag with Qundeftopic/fix-throw-false
* eval_intern.h (TH_PUSH_TAG): initialize 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 find an unrelated tag which is not created by Kernel#catch.
-rw-r--r--eval_intern.h2
-rw-r--r--test/ruby/test_exception.rb9
2 files changed, 10 insertions, 1 deletions
diff --git a/eval_intern.h b/eval_intern.h
index 9db0fd1..c5210b1 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 03c0c81..2b8a378 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)