Actions
Bug #20655
closedCalling continuation triggers ensure function of rb_ensure
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.4.0dev (2024-07-26T10:18:32Z test-ensure-called.. 9327e49d31) [arm64-darwin23]
Description
The bug is reproduced when:
-
rb_ensure(func1, arg1, func2, arg2)
is called with arguments:- func1: eventually calls
rb_f_require()
(orKernel#require
via rb_funcall) - func2: any C func
- the required ruby script requires 'continuation' and calls
callcc
+cont.call
- func1: eventually calls
In this situation, cont.call
triggers the func2
specified with rb_ensure
, even without any exceptions.
The func2
call is triggered every time when cont.call
is executed. If cont.call
happens multiple times, func2
will be called multiple times.
I created a pull-request to add the test case of this bug: https://github.com/ruby/ruby/pull/11254
And @ko1 (Koichi Sasada) -san said this bug is reproduceable by this code (Dir.chdir uses rb_ensure):
require 'continuation'
Dir.chdir('/tmp') do
p [__LINE__, tmp = Dir.pwd]
cont = nil
callcc{|c| cont = c}
p [__LINE__, Dir.pwd]
exit! if Dir.pwd != tmp
cont.call
end
Updated by mame (Yusuke Endoh) 5 months ago
I guess https://github.com/ruby/ruby/pull/11264 will solve your issue. Could you give it a try with your patch?
Updated by tagomoris (Satoshi Tagomori) 5 months ago
- Status changed from Open to Closed
Applied in changeset git|c884db0b5b4f5296e5eacd27357b730b42f27b3a.
[BUG #20655] Add tests to use rb_ensure and call cont.call
Actions
Like0
Like0Like0