ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-dev:43715] [Ruby 1.9 - Bug #595] Fiber ignores ensure clause
       [not found] <redmine.issue-595.20080924192809@ruby-lang.org>
@ 2011-06-11  5:52 ` Koichi Sasada
  2011-06-11 13:14   ` [ruby-dev:43744] " Yukihiro Matsumoto
  2011-06-11 13:23 ` [ruby-dev:43745] " Yui NARUSE
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 17+ messages in thread
From: Koichi Sasada @ 2011-06-11  5:52 UTC (permalink / raw)
  To: ruby developers list


Issue #595 has been updated by Koichi Sasada.


未だに考え中ですが,これは 1.9.3 には仕様変更になるので入りませんよね?
----------------------------------------
Bug #595: Fiber ignores ensure clause
http://redmine.ruby-lang.org/issues/595

Author: Koichi Sasada
Status: Assigned
Priority: Normal
Assignee: Koichi Sasada
Category: core
Target version: 1.9.x
ruby -v: ruby 1.9.2dev (2010-01-13) [i386-mingw32]


=begin
 Ruby プロセス終了時,Fiber が ensure を無視します.
 これは,前から直そうと思って手がついていなかった問題です.
 10月末までには直そうと思います.結構複雑なので,後回しにしていましました.
 
 fib = Fiber.new{
   begin
     Fiber.yield :ok
   ensure
     puts "should be print out"
   end
 }
 p fib.resume
=end



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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-dev:43744] Re: [Ruby 1.9 - Bug #595] Fiber ignores ensure clause
  2011-06-11  5:52 ` [ruby-dev:43715] [Ruby 1.9 - Bug #595] Fiber ignores ensure clause Koichi Sasada
@ 2011-06-11 13:14   ` Yukihiro Matsumoto
  0 siblings, 0 replies; 17+ messages in thread
From: Yukihiro Matsumoto @ 2011-06-11 13:14 UTC (permalink / raw)
  To: ruby developers list

まつもと ゆきひろです

In message "Re: [ruby-dev:43715] [Ruby 1.9 - Bug #595] Fiber ignores ensure clause"
    on Sat, 11 Jun 2011 14:52:03 +0900, Koichi Sasada <redmine@ruby-lang.org> writes:

|未だに考え中ですが,これは 1.9.3 には仕様変更になるので入りませんよね?

この動作はバグだと考えているので、Yuguiさんが拒絶しない限り、
直せるのであれば1.9.3で直せばよいと思います。間に合わないな
らしょうがない。

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-dev:43745] [Ruby 1.9 - Bug #595] Fiber ignores ensure clause
       [not found] <redmine.issue-595.20080924192809@ruby-lang.org>
  2011-06-11  5:52 ` [ruby-dev:43715] [Ruby 1.9 - Bug #595] Fiber ignores ensure clause Koichi Sasada
@ 2011-06-11 13:23 ` Yui NARUSE
  2011-06-26 14:24 ` [ruby-dev:43951] " Hiroshi Nakamura
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Yui NARUSE @ 2011-06-11 13:23 UTC (permalink / raw)
  To: ruby developers list


Issue #595 has been updated by Yui NARUSE.


RubySpec 的にバグ扱いになってますね。
core/fiber/resume_spec.rb
----------------------------------------
Bug #595: Fiber ignores ensure clause
http://redmine.ruby-lang.org/issues/595

Author: Koichi Sasada
Status: Assigned
Priority: Normal
Assignee: Koichi Sasada
Category: core
Target version: 1.9.x
ruby -v: -


=begin
 Ruby プロセス終了時,Fiber が ensure を無視します.
 これは,前から直そうと思って手がついていなかった問題です.
 10月末までには直そうと思います.結構複雑なので,後回しにしていましました.
 
 fib = Fiber.new{
   begin
     Fiber.yield :ok
   ensure
     puts "should be print out"
   end
 }
 p fib.resume
=end



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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-dev:43951] [Ruby 1.9 - Bug #595] Fiber ignores ensure clause
       [not found] <redmine.issue-595.20080924192809@ruby-lang.org>
  2011-06-11  5:52 ` [ruby-dev:43715] [Ruby 1.9 - Bug #595] Fiber ignores ensure clause Koichi Sasada
  2011-06-11 13:23 ` [ruby-dev:43745] " Yui NARUSE
@ 2011-06-26 14:24 ` Hiroshi Nakamura
  2012-03-13  6:06 ` [ruby-dev:45354] [ruby-trunk - Bug #595][Assigned] " Yui NARUSE
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Hiroshi Nakamura @ 2011-06-26 14:24 UTC (permalink / raw)
  To: ruby developers list


Issue #595 has been updated by Hiroshi Nakamura.

Target version changed from 1.9.x to 1.9.3


----------------------------------------
Bug #595: Fiber ignores ensure clause
http://redmine.ruby-lang.org/issues/595

Author: Koichi Sasada
Status: Assigned
Priority: Normal
Assignee: Koichi Sasada
Category: core
Target version: 1.9.3
ruby -v: -


=begin
 Ruby プロセス終了時,Fiber が ensure を無視します.
 これは,前から直そうと思って手がついていなかった問題です.
 10月末までには直そうと思います.結構複雑なので,後回しにしていましました.
 
 fib = Fiber.new{
   begin
     Fiber.yield :ok
   ensure
     puts "should be print out"
   end
 }
 p fib.resume
=end



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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-dev:45354] [ruby-trunk - Bug #595][Assigned] Fiber ignores ensure clause
       [not found] <redmine.issue-595.20080924192809@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2011-06-26 14:24 ` [ruby-dev:43951] " Hiroshi Nakamura
@ 2012-03-13  6:06 ` Yui NARUSE
  2012-07-25 10:08 ` [ruby-dev:46005] [ruby-trunk - Bug #595] " ko1 (Koichi Sasada)
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Yui NARUSE @ 2012-03-13  6:06 UTC (permalink / raw)
  To: ruby developers list


Issue #595 has been updated by Yui NARUSE.

Status changed from Closed to Assigned
Target version changed from 1.9.3 to 3.0


----------------------------------------
Bug #595: Fiber ignores ensure clause
https://bugs.ruby-lang.org/issues/595

Author: Koichi Sasada
Status: Assigned
Priority: Normal
Assignee: Koichi Sasada
Category: core
Target version: 3.0
ruby -v: -


=begin
 Ruby プロセス終了時,Fiber が ensure を無視します.
 これは,前から直そうと思って手がついていなかった問題です.
 10月末までには直そうと思います.結構複雑なので,後回しにしていましました.
 
 fib = Fiber.new{
   begin
     Fiber.yield :ok
   ensure
     puts "should be print out"
   end
 }
 p fib.resume
=end



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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-dev:46005] [ruby-trunk - Bug #595] Fiber ignores ensure clause
       [not found] <redmine.issue-595.20080924192809@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2012-03-13  6:06 ` [ruby-dev:45354] [ruby-trunk - Bug #595][Assigned] " Yui NARUSE
@ 2012-07-25 10:08 ` ko1 (Koichi Sasada)
  2012-07-25 13:24 ` [ruby-dev:46006] " naruse (Yui NARUSE)
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: ko1 (Koichi Sasada) @ 2012-07-25 10:08 UTC (permalink / raw)
  To: ruby developers list


Issue #595 has been updated by ko1 (Koichi Sasada).


あれ,これ 3.0 でいいんだっけ.
----------------------------------------
Bug #595: Fiber ignores ensure clause
https://bugs.ruby-lang.org/issues/595#change-28431

Author: ko1 (Koichi Sasada)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: 3.0
ruby -v: -


=begin
 Ruby プロセス終了時,Fiber が ensure を無視します.
 これは,前から直そうと思って手がついていなかった問題です.
 10月末までには直そうと思います.結構複雑なので,後回しにしていましました.
 
 fib = Fiber.new{
   begin
     Fiber.yield :ok
   ensure
     puts "should be print out"
   end
 }
 p fib.resume
=end



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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-dev:46006] [ruby-trunk - Bug #595] Fiber ignores ensure clause
       [not found] <redmine.issue-595.20080924192809@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2012-07-25 10:08 ` [ruby-dev:46005] [ruby-trunk - Bug #595] " ko1 (Koichi Sasada)
@ 2012-07-25 13:24 ` naruse (Yui NARUSE)
  2012-08-05  4:05 ` [ruby-dev:46030] " wanabe (_ wanabe)
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: naruse (Yui NARUSE) @ 2012-07-25 13:24 UTC (permalink / raw)
  To: ruby developers list


Issue #595 has been updated by naruse (Yui NARUSE).


ko1 (Koichi Sasada) wrote:
> あれ,これ 3.0 でいいんだっけ.

3月に話したときに大変そうだから先かなー的な雰囲気のことを仰っていたので、3.0かなぁ、と。
早く直るに越した事はありません。
----------------------------------------
Bug #595: Fiber ignores ensure clause
https://bugs.ruby-lang.org/issues/595#change-28435

Author: ko1 (Koichi Sasada)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: 3.0
ruby -v: -


=begin
 Ruby プロセス終了時,Fiber が ensure を無視します.
 これは,前から直そうと思って手がついていなかった問題です.
 10月末までには直そうと思います.結構複雑なので,後回しにしていましました.
 
 fib = Fiber.new{
   begin
     Fiber.yield :ok
   ensure
     puts "should be print out"
   end
 }
 p fib.resume
=end



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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-dev:46030] [ruby-trunk - Bug #595] Fiber ignores ensure clause
       [not found] <redmine.issue-595.20080924192809@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2012-07-25 13:24 ` [ruby-dev:46006] " naruse (Yui NARUSE)
@ 2012-08-05  4:05 ` wanabe (_ wanabe)
  2012-08-05 10:18   ` [ruby-dev:46031] " KOSAKI Motohiro
  2012-08-20  8:56   ` [ruby-dev:46060] " SASADA Koichi
  2014-01-13 10:59 ` [ruby-dev:47883] " Yura, Sokolov
                   ` (6 subsequent siblings)
  13 siblings, 2 replies; 17+ messages in thread
From: wanabe (_ wanabe) @ 2012-08-05  4:05 UTC (permalink / raw)
  To: ruby developers list


Issue #595 has been updated by wanabe (_ wanabe).

File ensure_fiber2.patch added

ワナベと申します。

(1) GC で mark と sweep の間に、mark されていない Fiber を対象に
(2) ruby_cleanup 中に、メインスレッドに所属するすべての Fiber を対象に
(3) 子スレッド終了時(vm->living_threads から外されるとき)、所属するすべての Fiber を対象に
の 3 つのタイミングで、throw/catch により ensure 節を実行するパッチを書きました。

[ruby-dev:41035] で遠藤さんがおっしゃっているような「yield 中の Fiber は GC しない」
という手法もやってみたのですが、test/ruby/test_fiber.rb がとても終わりそうにないことや
Fiber のマーク処理の重さや Fiber 自体のメモリ消費量などにより、断念しました。
そのため上記(1)のように、rb_gc_marked_p() という関数が必要になるなど強引な手段を使っています。

また、以下のようにして速度低下を計ってみました。

require "benchmark"
GC.start
Benchmark.bm(4) do |x|
  tms = Benchmark::Tms.new
  10.times do |i|
    tms += x.report("   #{i}:") do
      30000.times do
        Fiber.new{Fiber.yield}.resume
      end
    end
  end
  puts " sum:#{tms}"
end

素の r36623 :2.980000   3.120000   6.100000 (  6.107164)
パッチ適用後:3.580000   3.480000   7.060000 (  7.061093)

と、無視できない程度に(約 14%)速度低下してしまいました。
とはいえこれ以上の方法は思いつかないのですが、いかがでしょうか。
----------------------------------------
Bug #595: Fiber ignores ensure clause
https://bugs.ruby-lang.org/issues/595#change-28655

Author: ko1 (Koichi Sasada)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: 3.0
ruby -v: -


=begin
 Ruby プロセス終了時,Fiber が ensure を無視します.
 これは,前から直そうと思って手がついていなかった問題です.
 10月末までには直そうと思います.結構複雑なので,後回しにしていましました.
 
 fib = Fiber.new{
   begin
     Fiber.yield :ok
   ensure
     puts "should be print out"
   end
 }
 p fib.resume
=end



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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-dev:46031] Re: [ruby-trunk - Bug #595] Fiber ignores ensure clause
  2012-08-05  4:05 ` [ruby-dev:46030] " wanabe (_ wanabe)
@ 2012-08-05 10:18   ` KOSAKI Motohiro
  2012-08-20  8:56   ` [ruby-dev:46060] " SASADA Koichi
  1 sibling, 0 replies; 17+ messages in thread
From: KOSAKI Motohiro @ 2012-08-05 10:18 UTC (permalink / raw)
  To: ruby developers list

> 素の r36623 :2.980000   3.120000   6.100000 (  6.107164)
> パッチ適用後:3.580000   3.480000   7.060000 (  7.061093)
>
> と、無視できない程度に(約 14%)速度低下してしまいました。
> とはいえこれ以上の方法は思いつかないのですが、いかがでしょうか。

パッチはまったく見ていないのですが、速ければちゃんと動かなくてもいいという主張は
意味不明なので性能半分とかすごい数字にならなければ気にしてもしょうがないんじゃないでしょうか

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-dev:46060] Re: [ruby-trunk - Bug #595] Fiber ignores ensure clause
  2012-08-05  4:05 ` [ruby-dev:46030] " wanabe (_ wanabe)
  2012-08-05 10:18   ` [ruby-dev:46031] " KOSAKI Motohiro
@ 2012-08-20  8:56   ` SASADA Koichi
  1 sibling, 0 replies; 17+ messages in thread
From: SASADA Koichi @ 2012-08-20  8:56 UTC (permalink / raw)
  To: ruby developers list; +Cc: s.wanabe

こちら,返事が大変遅くなって済みません.

(2012/08/05 13:05), wanabe (_ wanabe) wrote:
> (1) GC で mark と sweep の間に、mark されていない Fiber を対象に
> (2) ruby_cleanup 中に、メインスレッドに所属するすべての Fiber を対象に
> (3) 子スレッド終了時(vm->living_threads から外されるとき)、所属するすべての Fiber を対象に
> の 3 つのタイミングで、throw/catch により ensure 節を実行するパッチを書きました。
> 
> [ruby-dev:41035] で遠藤さんがおっしゃっているような「yield 中の Fiber は GC しない」
> という手法もやってみたのですが、test/ruby/test_fiber.rb がとても終わりそうにないことや
> Fiber のマーク処理の重さや Fiber 自体のメモリ消費量などにより、断念しました。
> そのため上記(1)のように、rb_gc_marked_p() という関数が必要になるなど強引な手段を使っています。

 とりとめもなく3つほど.

 (1) ですが,ファイナライザのように実行するのはどうかと思っておりまし
た.ただ,その場合,ちょっと管理が大変なんですよね.


 あと,throw よりは,

#define eKillSignal INT2FIX(0)
#define eTerminateSignal INT2FIX(1)

この辺がいいのかなぁ,と思っていました.いや,むしろここを thorw にした
ほうが設計は綺麗かもしれませんね....現在のの実装は,絶対 catch 出来な
い,ってのを目指している感じです.


 速度ですが,小崎さんが仰っているように,あまり気にしてもしょうがない,
という気もするのですが,例えば ensure 節でひっかける可能性があるか,とい
うチェックをするのは結構効くのではないかと思っています.

 というのも,殆どの用途はガチで使っているわけじゃないと思うので,ensure
な処理を必要とする Fiber は,実は少ないのではないかと,

 別の案としては,Fiber 生成時に「ensure ちゃんと処理して」フラグを新設
し,ガチで使う人(ensure をきっちり動かして欲しい人)はこれでやってね
(参考: http://bugs.ruby-lang.org/issues/6694),というのはどうだろう,
とか思うんですが,ちょっと手抜きしすぎでしょうか.

-- 
// SASADA Koichi at atdot dot net

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-dev:47883] [ruby-trunk - Bug #595] Fiber ignores ensure clause
       [not found] <redmine.issue-595.20080924192809@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2012-08-05  4:05 ` [ruby-dev:46030] " wanabe (_ wanabe)
@ 2014-01-13 10:59 ` Yura, Sokolov
  2015-10-12 13:16 ` [ruby-dev:49299] [Ruby trunk " eregontp
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: Yura, Sokolov @ 2014-01-13 10:59 UTC (permalink / raw)
  To: ruby-dev

Задача #595 была обновлена (Yura Sokolov).


What about this ticket?
Guaranteed `ensure` inside of Fiber and Fiber.raise (as complement for Thread.raise) will be usefull for full coroutine based environment ala python's gevent.

----------------------------------------
Bug #595: Fiber ignores ensure clause
https://bugs.ruby-lang.org/issues/595#change-44261

* Автор: Koichi Sasada
* Статус: Assigned
* Приоритет: Normal
* Назначена: Koichi Sasada
* Категория: core
* Версия: Next Major
* ruby -v: -
* Backport: 
----------------------------------------
=begin
 Ruby プロセス終了時,Fiber が ensure を無視します.
 これは,前から直そうと思って手がついていなかった問題です.
 10月末までには直そうと思います.結構複雑なので,後回しにしていましました.
 
 fib = Fiber.new{
   begin
     Fiber.yield :ok
   ensure
     puts "should be print out"
   end
 }
 p fib.resume
=end


---Файлы--------------------------------
ensure_fiber.patch (2,123 КБ)
ensure_fiber2.patch (7,565 КБ)


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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-dev:49299] [Ruby trunk - Bug #595] Fiber ignores ensure clause
       [not found] <redmine.issue-595.20080924192809@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2014-01-13 10:59 ` [ruby-dev:47883] " Yura, Sokolov
@ 2015-10-12 13:16 ` eregontp
  2017-01-31  7:22 ` [ruby-dev:49967] [Ruby trunk Bug#595] " ko1
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: eregontp @ 2015-10-12 13:16 UTC (permalink / raw)
  To: ruby-dev

Issue #595 has been updated by Benoit Daloze.


Could we clarify what is the desired behavior and what prevents it to be implemented?

There is a very old RubySpec about this and I would like to know whether this might be guaranteed in a future release or not.

----------------------------------------
Bug #595: Fiber ignores ensure clause
https://bugs.ruby-lang.org/issues/595#change-54429

* Author: Koichi Sasada
* Status: Assigned
* Priority: Normal
* Assignee: Koichi Sasada
* ruby -v: -
* Backport: 
----------------------------------------
=begin
 Ruby プロセス終了時,Fiber が ensure を無視します.
 これは,前から直そうと思って手がついていなかった問題です.
 10月末までには直そうと思います.結構複雑なので,後回しにしていましました.
 
 fib = Fiber.new{
   begin
     Fiber.yield :ok
   ensure
     puts "should be print out"
   end
 }
 p fib.resume
=end


---Files--------------------------------
ensure_fiber.patch (2.12 KB)
ensure_fiber2.patch (7.57 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-dev:49967] [Ruby trunk Bug#595] Fiber ignores ensure clause
       [not found] <redmine.issue-595.20080924192809@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2015-10-12 13:16 ` [ruby-dev:49299] [Ruby trunk " eregontp
@ 2017-01-31  7:22 ` ko1
  2018-11-22  0:38 ` [ruby-dev:50675] " samuel
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: ko1 @ 2017-01-31  7:22 UTC (permalink / raw)
  To: ruby-dev

Issue #595 has been updated by Koichi Sasada.

Description updated

そろそろ手をつけようかなぁ。

----------------------------------------
Bug #595: Fiber ignores ensure clause
https://bugs.ruby-lang.org/issues/595#change-62755

* Author: Koichi Sasada
* Status: Assigned
* Priority: Normal
* Assignee: Koichi Sasada
* Target version: 
* ruby -v: -
* Backport: 
----------------------------------------

 Ruby プロセス終了時,Fiber が ensure を無視します.
 これは,前から直そうと思って手がついていなかった問題です.
 10月末までには直そうと思います.結構複雑なので,後回しにしていましました.

``` 
 fib = Fiber.new{
   begin
     Fiber.yield :ok
   ensure
     puts "should be print out"
   end
 }
 p fib.resume
```


---Files--------------------------------
ensure_fiber.patch (2.12 KB)
ensure_fiber2.patch (7.57 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-dev:50675] [Ruby trunk Bug#595] Fiber ignores ensure clause
       [not found] <redmine.issue-595.20080924192809@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2017-01-31  7:22 ` [ruby-dev:49967] [Ruby trunk Bug#595] " ko1
@ 2018-11-22  0:38 ` samuel
  2018-12-20  1:15 ` [ruby-dev:50722] " samuel
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 17+ messages in thread
From: samuel @ 2018-11-22  0:38 UTC (permalink / raw)
  To: ruby-dev

Issue #595 has been updated by ioquatix (Samuel Williams).


In a GC language, it's impossible to ensure this, unless you want the GC to invoke some functionality.

I suggest adding something like `Fiber#stop` which causes internally `Fiber#resume` to raise exception.

It should be up to user code to deal with this IMHO, e.g.

```
fib = Fiber.new{
  begin
    Fiber.yield :ok
  ensure
    puts "should be print out"
  end
}
begin
  p fib.resume
ensure
  fib.stop
end
```

I believe there is no logical solution to avoid this issue except making it explicit of consumer of fiber. It's the same reason why we should do the following:


```
f = File.open
begin
  f.write "..."
ensure
  f.close
end
```


----------------------------------------
Bug #595: Fiber ignores ensure clause
https://bugs.ruby-lang.org/issues/595#change-75026

* Author: ko1 (Koichi Sasada)
* Status: Assigned
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version: 
* ruby -v: -
* Backport: 
----------------------------------------

 Ruby プロセス終了時,Fiber が ensure を無視します.
 これは,前から直そうと思って手がついていなかった問題です.
 10月末までには直そうと思います.結構複雑なので,後回しにしていましました.

``` 
 fib = Fiber.new{
   begin
     Fiber.yield :ok
   ensure
     puts "should be print out"
   end
 }
 p fib.resume
```


---Files--------------------------------
ensure_fiber.patch (2.12 KB)
ensure_fiber2.patch (7.57 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-dev:50722] [Ruby trunk Bug#595] Fiber ignores ensure clause
       [not found] <redmine.issue-595.20080924192809@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2018-11-22  0:38 ` [ruby-dev:50675] " samuel
@ 2018-12-20  1:15 ` samuel
  2018-12-20  4:19 ` [ruby-dev:50723] " samuel
  2019-01-14  7:32 ` [ruby-dev:50763] " naruse
  13 siblings, 0 replies; 17+ messages in thread
From: samuel @ 2018-12-20  1:15 UTC (permalink / raw)
  To: ruby-dev

Issue #595 has been updated by ioquatix (Samuel Williams).

Assignee changed from ko1 (Koichi Sasada) to ioquatix (Samuel Williams)

While it's not possible unless we invoke functionality from the GC, if/when we merge https://bugs.ruby-lang.org/issues/10344 it should become simple to do the following

```
while fiber.alive?
    fiber.raise(Exception, "Time to die")
end
```

This would guarantee all ensure blocks are executed.

In theory you could implement `fiber.kill` which does this, and then invoke that from the GC in the finaliser.. but might be unexpected for user.

----------------------------------------
Bug #595: Fiber ignores ensure clause
https://bugs.ruby-lang.org/issues/595#change-75792

* Author: ko1 (Koichi Sasada)
* Status: Assigned
* Priority: Normal
* Assignee: ioquatix (Samuel Williams)
* Target version: 
* ruby -v: -
* Backport: 
----------------------------------------

 Ruby プロセス終了時,Fiber が ensure を無視します.
 これは,前から直そうと思って手がついていなかった問題です.
 10月末までには直そうと思います.結構複雑なので,後回しにしていましました.

``` 
 fib = Fiber.new{
   begin
     Fiber.yield :ok
   ensure
     puts "should be print out"
   end
 }
 p fib.resume
```


---Files--------------------------------
ensure_fiber.patch (2.12 KB)
ensure_fiber2.patch (7.57 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-dev:50723] [Ruby trunk Bug#595] Fiber ignores ensure clause
       [not found] <redmine.issue-595.20080924192809@ruby-lang.org>
                   ` (11 preceding siblings ...)
  2018-12-20  1:15 ` [ruby-dev:50722] " samuel
@ 2018-12-20  4:19 ` samuel
  2019-01-14  7:32 ` [ruby-dev:50763] " naruse
  13 siblings, 0 replies; 17+ messages in thread
From: samuel @ 2018-12-20  4:19 UTC (permalink / raw)
  To: ruby-dev

Issue #595 has been updated by ioquatix (Samuel Williams).

Target version set to next minor

After discussion, we decided that:

- Doing this in the GC is probably a bad idea.
- Ruby's general model for resource management is explicit, e.g. `f = File.open; f.close` or `File.open do |f| ... end`. The same model should apply to Fiber.
- We can implement something like `Fiber.kill` or `Fiber.close` which essentially invokes `Fiber.raise(Exception)` until the Fiber is dead.

We will test these ideas during 2.7 release. If there are any further thoughts about this approach, please feel free to add them here.

----------------------------------------
Bug #595: Fiber ignores ensure clause
https://bugs.ruby-lang.org/issues/595#change-75793

* Author: ko1 (Koichi Sasada)
* Status: Assigned
* Priority: Normal
* Assignee: ioquatix (Samuel Williams)
* Target version: next minor
* ruby -v: -
* Backport: 
----------------------------------------

 Ruby プロセス終了時,Fiber が ensure を無視します.
 これは,前から直そうと思って手がついていなかった問題です.
 10月末までには直そうと思います.結構複雑なので,後回しにしていましました.

``` 
 fib = Fiber.new{
   begin
     Fiber.yield :ok
   ensure
     puts "should be print out"
   end
 }
 p fib.resume
```


---Files--------------------------------
ensure_fiber.patch (2.12 KB)
ensure_fiber2.patch (7.57 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [ruby-dev:50763] [Ruby trunk Bug#595] Fiber ignores ensure clause
       [not found] <redmine.issue-595.20080924192809@ruby-lang.org>
                   ` (12 preceding siblings ...)
  2018-12-20  4:19 ` [ruby-dev:50723] " samuel
@ 2019-01-14  7:32 ` naruse
  13 siblings, 0 replies; 17+ messages in thread
From: naruse @ 2019-01-14  7:32 UTC (permalink / raw)
  To: ruby-dev

Issue #595 has been updated by naruse (Yui NARUSE).

Target version deleted (2.7)

Target version is used by release engineering; don't use this as just a goal.

----------------------------------------
Bug #595: Fiber ignores ensure clause
https://bugs.ruby-lang.org/issues/595#change-76298

* Author: ko1 (Koichi Sasada)
* Status: Assigned
* Priority: Normal
* Assignee: ioquatix (Samuel Williams)
* Target version: 
* ruby -v: -
* Backport: 
----------------------------------------

 Ruby プロセス終了時,Fiber が ensure を無視します.
 これは,前から直そうと思って手がついていなかった問題です.
 10月末までには直そうと思います.結構複雑なので,後回しにしていましました.

``` 
 fib = Fiber.new{
   begin
     Fiber.yield :ok
   ensure
     puts "should be print out"
   end
 }
 p fib.resume
```


---Files--------------------------------
ensure_fiber.patch (2.12 KB)
ensure_fiber2.patch (7.57 KB)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2019-01-14  7:32 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-595.20080924192809@ruby-lang.org>
2011-06-11  5:52 ` [ruby-dev:43715] [Ruby 1.9 - Bug #595] Fiber ignores ensure clause Koichi Sasada
2011-06-11 13:14   ` [ruby-dev:43744] " Yukihiro Matsumoto
2011-06-11 13:23 ` [ruby-dev:43745] " Yui NARUSE
2011-06-26 14:24 ` [ruby-dev:43951] " Hiroshi Nakamura
2012-03-13  6:06 ` [ruby-dev:45354] [ruby-trunk - Bug #595][Assigned] " Yui NARUSE
2012-07-25 10:08 ` [ruby-dev:46005] [ruby-trunk - Bug #595] " ko1 (Koichi Sasada)
2012-07-25 13:24 ` [ruby-dev:46006] " naruse (Yui NARUSE)
2012-08-05  4:05 ` [ruby-dev:46030] " wanabe (_ wanabe)
2012-08-05 10:18   ` [ruby-dev:46031] " KOSAKI Motohiro
2012-08-20  8:56   ` [ruby-dev:46060] " SASADA Koichi
2014-01-13 10:59 ` [ruby-dev:47883] " Yura, Sokolov
2015-10-12 13:16 ` [ruby-dev:49299] [Ruby trunk " eregontp
2017-01-31  7:22 ` [ruby-dev:49967] [Ruby trunk Bug#595] " ko1
2018-11-22  0:38 ` [ruby-dev:50675] " samuel
2018-12-20  1:15 ` [ruby-dev:50722] " samuel
2018-12-20  4:19 ` [ruby-dev:50723] " samuel
2019-01-14  7:32 ` [ruby-dev:50763] " naruse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).