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


I think it is from r58380.

before r58380, `rb_memerror` calls `rb_longjmp` via `rb_exc_raise` and clear raised_flag.
But now `rb_memerror` keeps raised_flag and just calls `EC_JUMP_TAG`.

`rb_threadptr_execute_interrupts` should raise `Interrupt` exception on hitting ctrl-c,
but just return immediately because `th->raised_flag` is truthy.

I've confirmed above behavior with the script to use `miniruby`.

```
begin
  "a" * 10000000000
ensure
  Thread.new(Thread.current) do |t|
    Thread.pass
    t.raise Interrupt
    sleep 0.01
    STDERR.puts "shutting down..."
    Process.kill :KILL, $$
  end
  sleep
end
```

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

* 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:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>