Project

General

Profile

Bug #1495

warn_printf is an unhealthy thing to have in rb_thread_schedule as it can cause recursion.

Added by JohnCarter (John Carter) about 10 years ago. Updated about 8 years ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 1.8.7 (2009-04-08 patchlevel 160) [i686-linux]
[ruby-core:23506]

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

History

#1

Updated by nobu (Nobuyoshi Nakada) about 10 years ago

=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

#2

Updated by JohnCarter (John Carter) about 10 years ago

=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

Also available in: Atom PDF