Project

General

Profile

Actions

Bug #12743

closed

throw(false) does not work as expected

Added by rhenium (Kazuki Yamaguchi) over 8 years ago. Updated about 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0dev (2016-09-09 trunk 56124) [x86_64-linux]
[ruby-core:77229]

Description

I expect UncaughtThrowError for these examples:

$ ruby -e'throw false'
-e: unexpected throw
$ ruby -e'Fiber.new{throw false}.resume'
$ ruby -e'Thread.new{throw false}.join'
-e:1: [BUG] thread_join: THROW_DATA should not reach here.
ruby 2.4.0dev (2016-09-09 trunk 56124) [x86_64-linux]

-- Control frame information -----------------------------------------------
<snip>

The cause is that Kernel#throw incorrectly finds a tag that is not created by Kernel#catch, because TH_PUSH_TAG() initializes rb_vm_tag::tag with 0.

The attached patch seems to fix the issue, by making TH_PUSH_TAG() initialize with Qundef that should never appear in Ruby code.


Files

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0