ruby-changes:47067
From: nobu <ko1@a...>
Date: Tue, 27 Jun 2017 12:46:01 +0900 (JST)
Subject: [ruby-changes:47067] nobu:r59181 (trunk): vm_insnhelper.c: break in once
nobu 2017-06-27 12:45:55 +0900 (Tue, 27 Jun 2017) New Revision: 59181 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59181 Log: 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] Modified files: trunk/test/ruby/test_exception.rb trunk/vm_insnhelper.c Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 59180) +++ vm_insnhelper.c (revision 59181) @@ -1083,13 +1083,13 @@ vm_throw_start(rb_thread_t *const th, rb https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1083 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 && Index: test/ruby/test_exception.rb =================================================================== --- test/ruby/test_exception.rb (revision 59180) +++ test/ruby/test_exception.rb (revision 59181) @@ -1080,4 +1080,15 @@ $stderr = $stdout; raise "\x82\xa0"') do https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L1080 } 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/