Backport #1495
closed
warn_printf is an unhealthy thing to have in rb_thread_schedule as it can cause recursion.
Added by JohnCarter (John Carter) over 15 years ago.
Updated over 5 years ago.
Description
=begin
warn_printf is an unhealthy thing to have in rb_thread_schedule as it can (especially if you are running -rprofile) recurse back into rb_thread_schedule.
This is unhealthy as rb_thread_schedule uses several static variables and hence is not reentrant. (I discovered this when the deadlock detection reported deadlock even though there was a runnable thread! There wasn't a runnable thread, the recursion from warn_printf had just woken a thread.)
Probably present in ruby-1.8.6 as well.
=end
=begin
Hi,
At Wed, 20 May 2009 10:32:36 +0900,
John Carter wrote in [ruby-core:23506]:
warn_printf is an unhealthy thing to have in
rb_thread_schedule as it can (especially if you are running
-rprofile) recurse back into rb_thread_schedule.
It should be used only just before deadlock execption.
This is unhealthy as rb_thread_schedule uses several static
variables and hence is not reentrant. (I discovered this when
the deadlock detection reported deadlock even though there
was a runnable thread! There wasn't a runnable thread, the
recursion from warn_printf had just woken a thread.)
No static variables is used in rb_thread_schedule() directly.
You may mean rb_thread_save_context() and
rb_thread_restore_context_0()? But warn_printf() shouldn't be
called there.
--
Nobu Nakada
=end
=begin
I was trying to track down a deadlock issue and the warn_printf were showing that one thread was still runnable! ie. Couldn't be deadlocked but was! What was happening was it was recursing into rb_thread_schedule and something was marking that thread as runnable again. Not a serious bug, but seriously confusing. Hence the choice of word "unhealthy". However, if anyone ever shifts warn_printf anywhere else in rb_thread_schedule it could easily change from "unhealthy" to "fatal".
=end
- Tracker changed from Bug to Backport
- Project changed from Ruby 1.8 to Backport187
- Description updated (diff)
- Status changed from Open to Closed
- ruby -v deleted (
ruby 1.8.7 (2009-04-08 patchlevel 160) [i686-linux])
Also available in: Atom
PDF
Like0
Like0Like0Like0