Description of problem: perl -i is very handy. It allows me to filter a file and replace it with the result. I can even use the -i.bak option to make a backup. However, if while writing the new version (with or without .bak) perl encounters a write error, it silently ignores it and destroys the original file regardless of the fact that the "filtered" replacement is incomplete. Even if I use .bak, and hence create a backup of the original, perl's failure makes it appear that the filtering process has completed normally, and the unsuspecting user may well remove the backup file. Version-Release number of selected component (if applicable): perl-5.10.0-87.fc12.x86_64 How reproducible: always (with a nearly-full partition) I've just done the following on a nearly-full partition: Start off with a two-byte file: $ echo b > j Use "perl -i" to filter that "in-place", increasing its size: $ perl -ni -e '/b/ and print "."x100000 . "\nlast\n"' j \ && echo 'success, supposedly' success, supposedly Perl didn't report any problem and has exited successfully. Sounds good. But. Check out the size of the result: $ wc -c j 65536 j That certainly looks wrong. 65536 (aka 64KiB) < 100000 + 6. We should see that final "last" line. $ tail -c 10 j; echo .......... Confirmed. Truncated file, and write failure not reported. The above was done both with Fedora 12's v5.10.0 and with blead (built minutes ago, v5.12.0-RC0-6-gd419ab1). Rerunning with "strace -e write perl ..., I see this: write(4, "................................"..., 4096) = 4096 ...(15 others, identical)... write(4, "................................"..., 4096) = -1 ENOSPC (No space left on device) ...(7 others, identical)... write(4, "................................"..., 1702) = -1 ENOSPC (No space left on device) Steps to Reproduce: as above Actual results: as above Expected results: perl reports the failure and does not destroy the input
Since this can result in data loss, I've raised severity to "high"
I created upstream ticket.
This message is a reminder that Fedora 12 is nearing its end of life. Approximately 30 (thirty) days from now Fedora will stop maintaining and issuing updates for Fedora 12. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as WONTFIX if it remains open with a Fedora 'version' of '12'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version prior to Fedora 12's end of life. Bug Reporter: Thank you for reporting this issue and we are sorry that we may not be able to fix it before Fedora 12 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora please change the 'version' of this bug to the applicable version. If you are unable to change the version, please add a comment here and someone will do it for you. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete. The process we are following is described here: http://fedoraproject.org/wiki/BugZappers/HouseKeeping
I've just reproduced the above failure on rawhide, using perl-5.10.1-120.fc13.x86_64
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle. Changing version to '19'. (As we did not run this process for some time, it could affect also pre-Fedora 19 development cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.) More information and reason for this action is here: https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora19
This package has changed ownership in the Fedora Package Database. Reassigning to the new owner of this component.
This message is a notice that Fedora 19 is now at end of life. Fedora has stopped maintaining and issuing updates for Fedora 19. It is Fedora's policy to close all bug reports from releases that are no longer maintained. Approximately 4 (four) weeks from now this bug will be closed as EOL if it remains open with a Fedora 'version' of '19'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 19 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
I have confirmed that this still affects rawhide (22-to-be).
This message is a reminder that Fedora 21 is nearing its end of life. Approximately 4 (four) weeks from now Fedora will stop maintaining and issuing updates for Fedora 21. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '21'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 21 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
A related new upstream bug report <https://rt.perl.org/Public/Bug/Display.html?id=127663>.
Fedora 22 changed to end-of-life (EOL) status on 2016-07-19. Fedora 22 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of Fedora please feel free to reopen this bug against that version. If you are unable to reopen this bug, please file a new report against the current release. If you experience problems, please add a comment to this bug. Thank you for reporting this bug and we are sorry it could not be fixed.
This message is a reminder that Fedora 23 is nearing its end of life. Approximately 4 (four) weeks from now Fedora will stop maintaining and issuing updates for Fedora 23. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '23'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 23 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
This message is a reminder that Fedora 24 is nearing its end of life. Approximately 2 (two) weeks from now Fedora will stop maintaining and issuing updates for Fedora 24. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '24'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 24 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
Perl 5.26.0 brought some improvements. In your use case, it recognizes failed write(2) and report it on the stderr and returns a non-zero exit code. The only drawback is the original file content is lost: # echo a > /mnt/t/j # perl -ni -e '/a/ and print "."x20000000 . "\nlast\n"' /mnt/t/j && echo 'success, supposedly' Failed to close in-place edit file /mnt/t/j: No space left on device # ls -l /mnt/t/j -rw-r--r--. 1 root root 1028096 Jul 26 10:27 /mnt/t/j # tail -c 10 /mnt/t/j; echo .......... I think I can close this bug report. Unfortunately it's impossible to port the change back to older perls because it's very intrusive.