[ruby-core:92487] [Ruby trunk Bug#15779] After NoMemoryError, ruby freezes and takes 100% CPU

From: s.wanabe@...
Date: 2019-04-30 06:32:16 UTC
List: ruby-core #92487
Issue #15779 has been updated by wanabe (_ wanabe).


How about this?

```
diff --git a/vm.c b/vm.c
index 41064f07c3..be394b0dae 100644
--- a/vm.c
+++ b/vm.c
@@ -1895,7 +1895,7 @@ vm_exec(rb_execution_context_t *ec, int mjit_enable_p)
     }
     else {
        result = ec->errinfo;
-        rb_ec_raised_reset(ec, RAISED_STACKOVERFLOW);
+        rb_ec_raised_reset(ec, RAISED_STACKOVERFLOW | RAISED_NOMEMORY);
         while ((result = vm_exec_handle_exception(ec, state, result, &initial)) == Qundef) {
             /* caught a jump, exec the handler */
             result = vm_exec_core(ec, initial);
```

----------------------------------------
Bug #15779: After NoMemoryError, ruby freezes and takes 100% CPU
https://bugs.ruby-lang.org/issues/15779#change-77832

* 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
----------------------------------------
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, run it and hit Ctrl-C. But `puts 'XXX'` does not reproduce it.


---Files--------------------------------
strace.txt (377 KB)


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

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

In This Thread

Prev Next