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
Actions
Like0
Like0Like0