Skip to content
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

BlockingFile operations after destructor run throw TypeErrors #85

Open
bwoebi opened this issue Aug 12, 2024 · 0 comments
Open

BlockingFile operations after destructor run throw TypeErrors #85

bwoebi opened this issue Aug 12, 2024 · 0 comments

Comments

@bwoebi
Copy link
Member

bwoebi commented Aug 12, 2024

PHP Fatal error:  Uncaught TypeError: fseek(): supplied resource is not a valid stream resource in /.../vendor/amphp/file/src/Driver/BlockingFile.php:184
Stack trace:
#0 /.../vendor/amphp/file/src/Driver/BlockingFile.php(184): fseek(Resource id #383, 0, 0)
#1 ...: Amp\File\Driver\BlockingFile->seek(0)

The cycle collector happened to first destroy the BlockingFile instance, then another class wanting to write to it in its destructor.
The fix would be trivial to just also set the handle to null in __destruct. Having it then emit a normal ClosedException.

I'm wondering though, do we really need an explicit fclose() call in BlockingFile destructor, and can't just have it automatically close whenever PHP frees the underlying resource? So that we can just continue using it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant