-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessing Tempfile after GC of UploadedFile will cause IOError #338
Comments
This would not be backwards compatible. I don't understand why a finalizer is used in |
A finalizer was used in the Tempfile case to close and unlink the Tempfile created, but it was never needed, because Tempfile defines its own file that closes and unlinks. Update the spec so that it actually tests that tempfiles are getting removed and unlinked.
A finalizer was used in the Tempfile case to close and unlink the Tempfile created, but it was never needed, because Tempfile defines its own finalizer that closes and unlinks. Update the spec so that it actually tests that tempfiles are getting removed and unlinked. This uses 500 tempfiles in the JRuby test because some lower values I tried failed CI. CRuby could likely get away with only a handle of tempfiles, but the spec uses 50 to be sure it doesn't fail.
Thanks, it should resolve the problem too. |
A finalizer was used in the Tempfile case to close and unlink the Tempfile created, but it was never needed, because Tempfile defines its own finalizer that closes and unlinks. Update the spec so that it actually tests that tempfiles are getting removed and unlinked. This uses 500 tempfiles in the JRuby test because some lower values I tried failed CI. CRuby could likely get away with only a handle of tempfiles, but the spec uses 50 to be sure it doesn't fail.
In PR #180,
@tempfile
ofRack::Test::UploadedFile
will be unlinked after GC, though we can get direct reference to it.This script can reproduce the problem. (name this as
test.rb
and run byruby ./test.rb
)To fix this, I think we should stop providing access to the
@tempfile
and returnself
for#tempfile
method instead.Rack::Test::UploadedFile
will delegate all missing methods to@tempfile
, so it won't break anything.The text was updated successfully, but these errors were encountered: