[#35027] [Ruby 1.9-Bug#4352][Open] [patch] Fix eval(s, b) backtrace; make eval(s, b) consistent with eval(s) — "James M. Lawrence" <redmine@...>

Bug #4352: [patch] Fix eval(s, b) backtrace; make eval(s, b) consistent with eval(s)

16 messages 2011/02/01

[#35114] [Ruby 1.9-Bug#4373][Open] http.rb:677: [BUG] Segmentation fault — Christian Fazzini <redmine@...>

Bug #4373: http.rb:677: [BUG] Segmentation fault

59 messages 2011/02/06

[#35171] [Ruby 1.9-Bug#4386][Open] encoding: directive does not affect regex expressions — mathew murphy <redmine@...>

Bug #4386: encoding: directive does not affect regex expressions

9 messages 2011/02/09

[#35237] [Ruby 1.9-Bug#4400][Open] nested at_exit hooks run in strange order — Suraj Kurapati <redmine@...>

Bug #4400: nested at_exit hooks run in strange order

12 messages 2011/02/15

[ruby-core:35237] [Ruby 1.9-Bug#4400][Open] nested at_exit hooks run in strange order

From: Suraj Kurapati <redmine@...>
Date: 2011-02-15 06:49:59 UTC
List: ruby-core #35237
Bug #4400: nested at_exit hooks run in strange order
http://redmine.ruby-lang.org/issues/show/4400

Author: Suraj Kurapati
Status: Open, Priority: Normal
Category: core
ruby -v: ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-linux]

Hello,

The documentation for Kernel#at_exit says "If multiple [at_exit] handlers are
registered, they are executed in reverse order of registration".  However, does
not seem to be true for nested at_exit hooks (registering an at_exit hook inside
another at_exit hook).  For example consider this code:

at_exit { puts :outer0 }
at_exit { puts :outer1_begin; at_exit { puts :inner1 }; puts :outer1_end }
at_exit { puts :outer2_begin; at_exit { puts :inner2 }; puts :outer2_end }
at_exit { puts :outer3 }

Here is the output of running this code with two Rubies:

ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-linux]
outer3
outer2_begin
outer2_end
outer1_begin
outer1_end
outer0
inner1
inner2

ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
outer3
outer2_begin
outer2_end
outer1_begin
outer1_end
outer0
inner1
inner2

Observe how inner1 and inner2 are executed in registration order after all 
non-nested hooks are executed in reverse registration order.  This seems very 
strange to me; I would expect nested at_exit hooks to be executed immediately 
(as follows) because we are already inside the at_exit phase of the program:

outer3
outer2_begin
inner2
outer2_end
outer1_begin
inner1
outer1_end
outer0

What do you think?  Thanks for your consideration.


----------------------------------------
http://redmine.ruby-lang.org

In This Thread

Prev Next