1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merge revision(s) 59181: [Backport #13680]

vm_insnhelper.c: break in once

	* vm_insnhelper.c (vm_throw_start): size of catch table has been
	  included in iseq_catch_table struct, which could be NULL, since
	  2.2.  e.g., proc-closure in `once'.
	  [ruby-core:81775] [Bug #13680]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@59543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2017-08-09 10:14:33 +00:00
parent 048a82a99d
commit 1a150fe07f
4 changed files with 24 additions and 7 deletions

View file

@ -1,3 +1,9 @@
Wed Aug 9 19:14:07 2017 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_insnhelper.c (vm_throw_start): size of catch table has been
included in iseq_catch_table struct, which could be NULL, since
2.2. e.g., proc-closure in `once'.
Wed Aug 9 19:09:20 2017 Nobuyoshi Nakada <nobu@ruby-lang.org>
* node.h (nd_line): should sign-extend. shifting `VALUE` extends

View file

@ -905,4 +905,15 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
}
end;
end
def test_break_in_once
assert_separately([], "#{<<-"begin;"}\n#{<<~'end;'}")
begin;
obj = Object.new
def obj.try
/#{break}/o
end
assert_raise(LocalJumpError, /proc-closure/) {obj.try}
end;
end
end

View file

@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.5"
#define RUBY_RELEASE_DATE "2017-08-09"
#define RUBY_PATCHLEVEL 353
#define RUBY_PATCHLEVEL 354
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 8

View file

@ -946,13 +946,13 @@ vm_throw_start(rb_thread_t *const th, rb_control_frame_t *const reg_cfp, enum ru
while (escape_cfp < eocfp) {
if (escape_cfp->ep == ep) {
const VALUE epc = escape_cfp->pc - escape_cfp->iseq->body->iseq_encoded;
const rb_iseq_t * const iseq = escape_cfp->iseq;
const struct iseq_catch_table * const ct = iseq->body->catch_table;
const int ct_size = ct->size;
int i;
const rb_iseq_t *const iseq = escape_cfp->iseq;
const VALUE epc = escape_cfp->pc - iseq->body->iseq_encoded;
const struct iseq_catch_table *const ct = iseq->body->catch_table;
unsigned int i;
for (i=0; i<ct_size; i++) {
if (!ct) break;
for (i=0; i < ct->size; i++) {
const struct iseq_catch_table_entry * const entry = &ct->entries[i];;
if (entry->type == CATCH_TYPE_BREAK && entry->start < epc && entry->end >= epc) {