Bug #8768

[PATCH] tempfile: undefine finalizer on unlink

Added by Eric Wong 8 months ago. Updated 6 months ago.

[ruby-core:56521]
Status:Closed
Priority:Normal
Assignee:Nobuyoshi Nakada
Category:lib
Target version:2.1.0
ruby -v:ruby 2.1.0dev (2013-08-10 trunk 42491) [x86_64-linux] Backport:1.9.3: DONE, 2.0.0: DONE

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. rbiofptr_finalize will take care of closing
the descriptor without the extra finalizer for Tempfile.

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

Associated revisions

Revision 43110
Added by Nobuyoshi Nakada 7 months ago

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 [Bug #8768]

History

#1 Updated by Yui NARUSE 7 months ago

  • Status changed from Open to Assigned
  • Assignee set to Nobuyoshi Nakada

I know you are not the maintainer but could you review and commit this?

#2 Updated by Nobuyoshi Nakada 7 months ago

=begin
I couldn't let the test fail with the current code, but succeeded by setting $DEBUG at the end.

def testtempfilefinalizerdoesnotrunifunlinked
args = %w(--disable-gems -rtempfile)
assert
inouterr(args, <<-'EOS') do |(filename), (error)|
tmp = Tempfile.new('foo')
puts tmp.path
tmp.unlink
$DEBUG = true
EOS
assertfile.notexist?(filename)
assert_nil error, "we used to get a confusing 'removing ...done' here"
end
end
=end

#3 Updated by Nobuyoshi Nakada 7 months ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: REQUIRED, 2.0.0: REQUIRED

#4 Updated by Nobuyoshi Nakada 7 months 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 [Bug #8768]

#5 Updated by Tomoyuki Chikanaga 6 months 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 ruby20_0 at r43229.

#6 Updated by Usaku NAKAMURA 6 months ago

  • Backport changed from 1.9.3: REQUIRED, 2.0.0: DONE to 1.9.3: DONE, 2.0.0: DONE

Backported to ruby19_3 at r43490.

Also available in: Atom PDF