Project

General

Profile

Actions

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) almost 15 years ago. Updated almost 5 years ago.

Status:
Closed
Assignee:
-
[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

Actions #1

Updated by nobu (Nobuyoshi Nakada) almost 15 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

Actions #2

Updated by JohnCarter (John Carter) almost 15 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

Actions #3

Updated by jeremyevans0 (Jeremy Evans) almost 5 years ago

  • 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])
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0