Doc #54902 [Com]: fseek inconsistencies with large (>2GB) files
[email protected] ("farid dot jamili4118 at gmail dot com") Thu, 22 Dec 2022 06:06:09 +0000
| Newsgroups | php.doc.bugs |
|---|---|
| Message-ID | <[email protected]> |
Edit report at https://bugs.php.net/bug.php?id=54902&edit=1 ID: 54902 Comment by: farid dot jamili4118 at gmail dot com Reported by: zingaburga at hotmail dot com Summary: fseek inconsistencies with large (>2GB) files Status: Open Type: Documentation Problem Package: Filesystem function related Operating System: Windows 7 PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: That would make the pastebin example to behave reasonably. However, that also would prohibit to read beyond the 2GB limit, so would likely break working code, and remove a basically working feature. (https://www.dunkinrunsonyou.online/)php.net Previous Comments: ------------------------------------------------------------------------ [2020-10-06 13:38:31] [email protected] I think we should leave that as is, but document the behavior. ------------------------------------------------------------------------ [2020-09-01 12:27:22] [email protected] Related To: Bug #74395 ------------------------------------------------------------------------ [2020-08-31 08:32:02] [email protected] The following pull request has been associated: Patch Name: Fix #54902: fseek inconsistencies with large (>2GB) files On GitHub: https://github.com/php/php-src/pull/6055 Patch: https://github.com/php/php-src/pull/6055.patch ------------------------------------------------------------------------ [2020-08-14 14:20:06] [email protected] The following patch has been added/updated: Patch Name: position-no-overflow Revision: 1597414806 URL: https://bugs.php.net/patch-display.php?bug=54902&patch=position-no-overflow&revision=1597414806 ------------------------------------------------------------------------ [2020-08-14 14:19:40] [email protected] Ugh, that is indeed ugly. One way to fix this inconsistency would be to avoid the stream.position to overflow (see the attached position-no-overflow patch, which doesn't cater to writing, though). That would make the pastebin example to behave reasonably. However, that also would prohibit to read beyond the 2GB limit, so would likely break working code, and remove a basically working feature. Other than that, we could make the stream.position unsigned. That still would cause issues, because the stream layer converts SEEK_CUR seeks to SEEK_SET[1] to cater to stream.position which is not necessarily what ftell() would report (if the stream even supports something like ftell()). However, fseek() (or rather lseek() which is used internally) expect signed offsets, so we still couldn't seek beyond the 2GB limit – unless we'd rely on large file support. Not sure if that would be worth the trouble nowadays. [1] <https://github.com/php/php-src/blob/php-7.3.21/main/streams/streams.c#L1286-L1291> ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=54902 -- Edit this bug report at https://bugs.php.net/bug.php?id=54902&edit=1