From: "ibc (Iñaki Baz Castillo)" Date: 2012-05-15T08:06:25+09:00 Subject: [ruby-core:45044] [ruby-trunk - Bug #6433] rb_thread_blocking_region(): ubf() function is executed with GVL Issue #6433 has been updated by ibc (I��aki Baz Castillo). ibc (I��aki Baz Castillo) wrote: > > Maybe you expect that ubf() was called by *blocking* thread. However, > > it is not. > > Hi, within my ubf() function I printf the value of ruby_thread_has_gvl_p() and I get 1. My fault, the *blocking* thread is the one without GVL :) ---------------------------------------- Bug #6433: rb_thread_blocking_region(): ubf() function is executed with GVL https://bugs.ruby-lang.org/issues/6433#change-26626 Author: ibc (I��aki Baz Castillo) Status: Open Priority: Normal Assignee: Category: ext Target version: 1.9.2 ruby -v: ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux] thread.c says: ------------------------ * If another thread interrupts this thread (Thread#kill, signal delivery, * VM-shutdown request, and so on), `ubf()' is called (`ubf()' means * "un-blocking function"). `ubf()' should interrupt `func()' execution. * NOTE: You can not execute most of Ruby C API and touch Ruby * objects in `func()' and `ubf()', including raising an * exception, because current thread doesn't acquire GVL * (cause synchronization problem). VALUE rb_thread_blocking_region( rb_blocking_function_t *func, void *data1, rb_unblock_function_t *ubf, void *data2) -------------------------- I've created my ubf() function which is called when the Ruby thread in which rb_thread_blocking_region() was called is killed or interrupted. Within my ubf() function I expect not to have the GVL (as the doc says) and I need to run Ruby code, so I use: rb_thread_call_with_gvl(terminate_my_C_reactor_with_gvl, NULL); and I get an error: [BUG] rb_thread_call_with_gvl: called by a thread which has GVL. So... is ubf() called with the GVL or not?? -- http://bugs.ruby-lang.org/