Ruby process hang in ensure
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:
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
Timeoutis unnecessary and was added to illustrate that it has no effect to interrupt hanged process.
Process.pidis printed for convenience to kill hanged process.
valuein ensure changes behavior, there is no hang when encountering
value if nilbelow.
I've also checked
ruby 2.6.0preview3 (2018-11-06 trunk 65578) [x86_64-darwin18] and the problem persists.
Fix infinite loop by ensure
- compile.c (iseq_insert_nop_between_end_and_cont): insert nop so that the end of rescue and continuing points are not same, to get rid of infinite loop. [Bug #15385]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
#3 [ruby-core:90373] Updated by pawelpacana (Paweł Pacana) 5 days ago
#5 Updated by nobu (Nobuyoshi Nakada) 2 days ago
- Status changed from Open to Closed