Skip to content

Commit

Permalink
eval_intern.h: make TH_PUSH_TAG() initialize rb_vm_tag::tag with Qundef
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rhenium committed Sep 26, 2016
1 parent 64f53f0 commit ed5a926
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
Mon Sep 26 15:43:34 2016 Kazuki Yamaguchi <[email protected]>

* 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 <[email protected]>

* lib/tempfile.rb: provide default basename parameter for
Expand Down
2 changes: 1 addition & 1 deletion eval_intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() \
Expand Down
9 changes: 9 additions & 0 deletions test/ruby/test_exception.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,15 @@ def test_catch_throw_in_require
}
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)
Expand Down

0 comments on commit ed5a926

Please sign in to comment.