ruby-changes:46292
From: nobu <ko1@a...>
Date: Thu, 20 Apr 2017 00:14:07 +0900 (JST)
Subject: [ruby-changes:46292] nobu:r58405 (trunk): fix infinite recursion
nobu 2017-04-20 00:14:03 +0900 (Thu, 20 Apr 2017) New Revision: 58405 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58405 Log: fix infinite recursion * vm_insnhelper.c (vm_once_dispatch): no guarantee that tail call is always optimized away. Modified files: trunk/vm_insnhelper.c Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 58404) +++ vm_insnhelper.c (revision 58405) @@ -3238,8 +3238,9 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L3238 vm_once_dispatch(ISEQ iseq, IC ic, rb_thread_t *th) { rb_thread_t *const RUNNING_THREAD_ONCE_DONE = (rb_thread_t *)(0x1); - union iseq_inline_storage_entry *is = (union iseq_inline_storage_entry *)ic; + union iseq_inline_storage_entry *const is = (union iseq_inline_storage_entry *)ic; + again: if (is->once.running_thread == RUNNING_THREAD_ONCE_DONE) { return is->once.value; } @@ -3260,7 +3261,7 @@ vm_once_dispatch(ISEQ iseq, IC ic, rb_th https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L3261 /* waiting for finish */ RUBY_VM_CHECK_INTS(th); rb_thread_schedule(); - return vm_once_dispatch(iseq, ic, th); + goto again; } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/