Project

General

Profile

Actions

Bug #8768

closed

[PATCH] tempfile: undefine finalizer on unlink

Added by normalperson (Eric Wong) over 11 years ago. Updated about 11 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 2.1.0dev (2013-08-10 trunk 42491) [x86_64-linux]
[ruby-core:56521]

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

0001-lib-tempfile.rb-Tempfile-unlink-undefine-finalizer.patch (1.84 KB) 0001-lib-tempfile.rb-Tempfile-unlink-undefine-finalizer.patch patch incuding testcase normalperson (Eric Wong), 08/11/2013 04:41 AM

Updated by naruse (Yui NARUSE) over 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) over 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) about 11 years ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: REQUIRED, 2.0.0: REQUIRED
Actions #4

Updated by nobu (Nobuyoshi Nakada) about 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]
Actions #5

Updated by nagachika (Tomoyuki Chikanaga) about 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) about 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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0