Issue #15779 has been updated by buzztaiki (Taiki Sugawara).


Sorry, I wote bug report in Japanese to ruby-core.

In English:

Subject: After NoMemoryError, ruby freezes and takes 100% CPU

Description:
Run following reproduce code, ruby freezes and takes 100% CPU.

```
require 'open-uri'

begin
  "a" * 10000000000
ensure
  p open('https://www.ruby-lang.org/')
end
```

But interestingly, the following code does not reproduce this issue.

```
require 'open-uri'

begin
  begin
    "a" * 10000000000
  rescue NoMemoryError
    raise
  end
ensure
  p open('https://www.ruby-lang.org/')
end
```

It was also reproduced when put `sleep 100` in ensure clause. But `puts 'XXX'` does not reproduce it.


----------------------------------------
Bug #15779: NoMemoryError 後の ensure で ruby が CPU 100% で固まる現象
https://bugs.ruby-lang.org/issues/15779#change-77688

* Author: buzztaiki (Taiki Sugawara)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-linux]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
以下の再現用コードを実行すると、ruby が CPU 100% で固まってしまいます。

```
require 'open-uri'

begin
  "a" * 10000000000
ensure
  p open('https://www.ruby-lang.org/')
end
```

不思議なことに、以下のように一度 NoMemoryError を rescue してから raise すると再現しません。

```
require 'open-uri'

begin
  begin
    "a" * 10000000000
  rescue NoMemoryError
    raise
  end
ensure
  p open('https://www.ruby-lang.org/')
end
```

ensure 節を `sleep 100` 等にして Ctrl-C を押した場合でも再現するようです。`puts 'XXX'` にした場合では再現しませんでした。



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

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>