Issue #15385 has been updated by pawelpacana (Pawe Pacana).


> ujihisa (Tatsuhiro Ujihisa) wrote:
> looks like this is because the optimizer removed `if false` or `if nil` without adding `nop` iseq.

Could it be related then to https://bugs.ruby-lang.org/issues/14959#note-7 and https://bugs.ruby-lang.org/issues/15392 then?

----------------------------------------
Bug #15385: Ruby process hang in ensure
https://bugs.ruby-lang.org/issues/15385#change-75483

* Author: pawelpacana (Pawe Pacana)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
While playing with mutation testing of my code I've found a weird mutation that hangs Ruby process. The isolated code which triggers this freeze is:


~~~ ruby
require 'timeout'

puts Process.pid

def raise_before_returning
  raise
  []
end

def doh
  value = raise_before_returning
ensure
  # p value # <-- that unblocks it
  value if nil
end

Timeout.timeout(3) do
  doh
end
~~~

1. `Timeout` is unnecessary and was added to illustrate that it has no effect to interrupt hanged process.
2. `Process.pid` is printed for convenience to kill hanged process.
3. Printing `value` in ensure changes behavior, there is no hang when encountering `value if nil` below.

I've also checked `ruby 2.6.0preview3 (2018-11-06 trunk 65578) [x86_64-darwin18]` and the problem persists.
 

---Files--------------------------------
reproduce.rb (216 Bytes)


-- 
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>