-
Notifications
You must be signed in to change notification settings - Fork 560
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
Use of uninitialized value $this in <HANDLE> #17435
Comments
After a bit of time trying to reproduce it, I think in the original report there is a backslash () missing in IO::File->new:
|
markdown magic. I added quoting and now it reads right. |
I see warnings even in 5.18.2, just not as many:
It doesn't happen in 5.14:
I expect this was introduced in 986a805 which made getline() act as if it was in the caller's scope, and the re-work for that in 986a805 hasn't changed that. The warnings are generated when the various hooks PerlIO::scalar are called by the implementation of sv_gets() (called by do_readline(), called by pp_readline), those hooks have no way to tell when that readline operation starts and ends so we can't really limit the number of warnings produced to one per readline(). The warning could be considered reasonable, but I think it's way over punishing to report it many times per operation and reporting it on a readline() (aka getline()) could be confusing, since the handle might be passed in from some other code. So I think PerlIO::scalar should be modified to prevent those warnings. It might be reasonable to have warning on open, but the PerlIOScalar_pushed() handler carefully avoids warning on an undef SV and it probably not worthwhile changing that. One other issue from reviewing the code while checking out the warning sources - the various functions PerlIOScalar_get_base(), PerlIOScalar_get_ptr(), PerlIOScalar_get_cnt), PerlIOScalar_set_ptrcnt() all directly or indirectly call get magic, if the underlying magic ends up returning different SVs those values will end up being inconsistent at best. PerlIOScalar_read() avoids this for the read operation, but that doesn't help for sv_gets() or anything else that peeks at the buffer. Unfortunately I don't see a way to make that safe in the general case. |
Transferred from RT - https://rt.cpan.org/Ticket/Display.html?id=125436
IO::File started throwing warnings on getline(), if there wasn't writing to file before.
Commenting this line fixing the warning https://metacpan.org/source/TODDR/IO-1.39/lib/IO/Handle.pm#L435
The text was updated successfully, but these errors were encountered: