Bug #8768
closed[PATCH] tempfile: undefine finalizer on unlink
Description
- lib/tempfile.rb (Tempfile#unlink): undefine finalizer
running the finalizer on an unlinked Tempfile leads to a confusing
"removing ...done" message when using --debug. We can rely on
normal GC to close. rb_io_fptr_finalize will take care of closing
the descriptor without the extra finalizer for Tempfile.
Files
Updated by naruse (Yui NARUSE) almost 11 years ago
- Status changed from Open to Assigned
- Assignee set to nobu (Nobuyoshi Nakada)
I know you are not the maintainer but could you review and commit this?
Updated by nobu (Nobuyoshi Nakada) almost 11 years ago
=begin
I couldn't let the test fail with the current code, but succeeded by setting $DEBUG at the end.
def test_tempfile_finalizer_does_not_run_if_unlinked
args = %w(--disable-gems -rtempfile)
assert_in_out_err(args, <<-'EOS') do |(filename), (error)|
tmp = Tempfile.new('foo')
puts tmp.path
tmp.unlink
$DEBUG = true
EOS
assert_file.not_exist?(filename)
assert_nil error, "we used to get a confusing 'removing ...done' here"
end
end
=end
Updated by nobu (Nobuyoshi Nakada) almost 11 years ago
- Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: REQUIRED, 2.0.0: REQUIRED
Updated by nobu (Nobuyoshi Nakada) almost 11 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r43110.
Eric, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
tempfile.rb: undefine finalizer on unlink
- lib/tempfile.rb (Tempfile#unlink): finalizer is no longer needed
after unlinking. patched by by normalperson (Eric Wong) at
[ruby-core:56521] [Bug #8768]
Updated by nagachika (Tomoyuki Chikanaga) almost 11 years ago
- Backport changed from 1.9.3: REQUIRED, 2.0.0: REQUIRED to 1.9.3: REQUIRED, 2.0.0: DONE
backport r43110 and r43155 to ruby_2_0_0 at r43229.
Updated by usa (Usaku NAKAMURA) almost 11 years ago
- Backport changed from 1.9.3: REQUIRED, 2.0.0: DONE to 1.9.3: DONE, 2.0.0: DONE
Backported to ruby_1_9_3 at r43490.