Skip to content

Ignore EACCES when unlinking a tempfile from the finalizer - #82

Merged
hsbt merged 2 commits into
masterfrom
claude/cool-diffie-da734a
Sep 26, 2026
Merged

hsbt merged 2 commits into
masterfrom
claude/cool-diffie-da734a

Conversation

@hsbt

@hsbt hsbt commented Sep 26, 2026

Copy link
Copy Markdown
Member

On Windows, when another handle still holds a tempfile open at GC time, Tempfile::FinalizerManager#call gets Errno::EACCES from File.unlink and the exception leaks to stderr as "Exception in finalizer". Tempfile#unlink already ignores EACCES, so I made the finalizer do the same.

This is a forward-port of ruby/ruby#19029 (ruby/ruby@75d5467039 and ruby/ruby@b5245a5d33). The second commit stubs File.unlink with a prepended module instead of redefining it, so the test stays quiet under RUBYOPT=-w.

Generated with Claude Code

hsbt and others added 2 commits September 26, 2026 13:38
On Windows, File.unlink raises Errno::EACCES while another handle still holds the file open. Tempfile#unlink already ignores that, but FinalizerManager#call only rescued ENOENT, so the exception escaped from the GC finalizer and was reported on stderr.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Redefining the method warns under RUBYOPT=-w, which CI uses, and the test expects nothing on stderr. Prepending a module leaves the original method in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hsbt
hsbt merged commit 6518749 into master Sep 26, 2026
62 checks passed
@hsbt
hsbt deleted the claude/cool-diffie-da734a branch September 26, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant