php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54902 fseek inconsistencies with large (>2GB) files
Submitted: 2011-05-22 05:24 UTC Modified: 2020-10-06 13:38 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: zingaburga at hotmail dot com Assigned:
Status: Open Package: Filesystem function related
PHP Version: 5.3.6 OS: Windows 7
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: zingaburga at hotmail dot com
New email:
PHP Version: OS:

 

 [2011-05-22 05:24 UTC] zingaburga at hotmail dot com
Description:
------------
Firstly, I'm aware that fseek/ftell doesn't necessarily work correctly with >2GB files with 32-bit PHP due to integer range constraints, however, fseek operates rather inconsistently when passing 2GB, which would be nice if fixed (note that I've put this as a feature request, as it's a nice to have, and unsure if you'd classify this as a bug).

I'm using the 32-bit Windows build from here: http://windows.php.net/download/

See example script [ http://pastebin.com/Zb0vRgWX ] with comments for more info.
I haven't looked at PHP's source code, but from the behaviour of the script, I'm guessing that fseek does some checks, and because it's overflowing, it won't allow certain operations.  I'm not sure about the weird 8192 byte limit though.
As fread allows overflows, would it be possible to allow fseek to overflow too?

(PS first time I've submitted a "bug" - I hope I've done it correctly >_>)


Patches

position-no-overflow (last revision 2020-08-14 14:20 UTC by cmb@php.net)

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-22 05:50 UTC] zingaburga at hotmail dot com
If you're wondering, I'm using the following function to try to get around the fseek limitations.  It works, but it's really slow for large seeks.  If the 8KB limitation could be lifted, then this function could be serveral times faster.

http://pastebin.com/xWiQxgSB
 [2020-08-14 14:19 UTC] cmb@php.net
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>
 [2020-08-14 14:20 UTC] cmb@php.net
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-18 15:53 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-08-31 08:32 UTC] cmb@php.net
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-10-06 13:38 UTC] cmb@php.net
-Status: Assigned +Status: Open -Type: Feature/Change Request +Type: Documentation Problem -Assigned To: cmb +Assigned To:
 [2020-10-06 13:38 UTC] cmb@php.net
I think we should leave that as is, but document the behavior.
 [2022-12-22 06:06 UTC] farid dot jamili4118 at gmail dot com
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
 [2023-04-07 18:29 UTC] africanorthjourneys at gmail dot com
wonderful blog full of value thanks for the sharing


(https://morocco-itinerary.com/es/tour/2-dias-desde-marrakech-al-desierto-2/)github.com

(https://morocco-itinerary.com/es/tour/recomendaciones-para-viajar-a-marruecos/)github.com

(https://morocco-itinerary.com/es/tour/escapada-marrakech-3-dias/)github.com

(https://morocco-itinerary.com/es/tour/marruecos-en-4-dias-que-hacer/)github.com

(https://morocco-itinerary.com/es/tour/marruecos-viaje-5-dias/)github.com

(https://morocco-itinerary.com/es/tour/vacaciones-en-marruecos-5-dias/)github.com

(https://morocco-itinerary.com/es/tour/6-dias-en-marruecos-viajes/)github.com

(https://morocco-itinerary.com/es/tour/itinerario-marruecos-7-dias/)github.com

(https://morocco-itinerary.com/es/tour/visitar-marruecos-en-7-dias/)github.com

(https://morocco-itinerary.com/es/tour/marruecos-8-dias/)github.com

(https://morocco-itinerary.com/es/tour/tour-marruecos-de-9-dias/)github.com

(https://morocco-itinerary.com/es/tour/visitar-marruecos-en-10-dias/)github.com

(https://morocco-itinerary.com/es/tour/ruta-marruecos-10-dias/)github.com

(https://morocco-itinerary.com/es/tour/gran-vuelta-a-marruecos-en-11-dias/)github.com

(https://morocco-itinerary.com/es/tour/tour-por-marruecos-12-dias/)github.com

(https://morocco-itinerary.com/es/tour/2-dias-viajes-en-marruecos-desde-fez-al-desierto/)github.com

(https://morocco-itinerary.com/es/tour/3-dias-desde-fez-al-desierto-de-merzouga/)github.com

(https://morocco-itinerary.com/es/tour/3-dias-de-fez-a-marrakech-por-el-desierto/)github.com

(https://morocco-itinerary.com/es/tour/4-dias-desde-fez-al-desierto-y-marrakech-2/)github.com

(https://morocco-itinerary.com/es/tour/marruecos-4-dias-desde-fez-al-desierto/)github.com

(https://morocco-itinerary.com/es/tour/marruecos-5-dias-4-noches-desde-marrakech/)github.com

(https://morocco-itinerary.com/es/tour/circuito-marruecos-6-dias/)github.com

(https://morocco-itinerary.com/es/tour/viaje-de-7-dias-en-marruecos-desde-fez/)github.com


(https://morocco-itinerary.com/es/tour/viaje-marruecos-7-dias/)github.com


(https://morocco-itinerary.com/es/tour/circuito-por-marruecos-8-dias/)github.com

(https://morocco-itinerary.com/es/tour/marruecos-en-9-dias/)github.com

(https://morocco-itinerary.com/es/tour/mejor-10-dias-en-marruecos/)github.com

(https://morocco-itinerary.com/es/tour/recorrer-marruecos-en-10-dias/)github.com

(https://morocco-itinerary.com/es/tour/ruta-de-10-dias-en-marruecos-desde-fez/)github.com

(https://morocco-itinerary.com/es/tour/11-dias-en-marruecos-desierto-y-ciudades-imperiales/)github.com


(https://morocco-itinerary.com/es/tour/tour-de-12-dias-en-marruecos/)github.com


(https://morocco-itinerary.com/es/tour/tour-de-13-dias-en-marruecos/)github.com

(https://morocco-itinerary.com/es/tour/tour-norte-de-marruecos-4-dias/)github.com

(https://morocco-itinerary.com/es/tour/5-dias-de-viaje-a-marruecos-desde-casablanca/)github.com

(https://morocco-itinerary.com/es/tour/ruta-por-marruecos-en-6-dias-desde-casablanca/)github.com

(https://morocco-itinerary.com/es/tour/viaje-de-7-dias-al-norte-de-marruecos/)github.com

(https://morocco-itinerary.com/es/tour/viaje-de-7-dias-alrededor-de-marruecos/)github.com

(https://morocco-itinerary.com/es/tour/excursion-desde-casablanca-8-dias/)github.com

(hhttps://morocco-itinerary.com/es/tour/viaje-privado-de-9-dias-por-marruecos/)github.com

(https://morocco-itinerary.com/es/tour/marruecos-viaje-por-10-dias/)github.com

(https://morocco-itinerary.com/es/tour/descubra-marruecos-en-10-dias/)github.com

(https://morocco-itinerary.com/es/tour/ruta-de-11-dias-por-marruecos-desde-casablanca/)github.com

(https://morocco-itinerary.com/es/tour/tour-de-12-dias-por-marruecos-desde-casablanca/)github.com

(https://morocco-itinerary.com/es/tour/ruta-de-13-dias-en-marruecos-desde-casablanca/)github.com

(https://morocco-itinerary.com/es/tour/marruecos-en-13-dias-de-viaje-desde-casablanca/)github.com

(https://morocco-itinerary.com/es/tour/ruta-de-14-dias-en-marruecos-desde-casablanca/)github.com

(https://morocco-itinerary.com/es/tour/5-dias-en-el-norte-de-marruecos-desde-tanger/)github.com

(https://morocco-itinerary.com/es/tour/ruta-de-6-dias-desde-en-marruecos/)github.com

(https://morocco-itinerary.com/es/tour/ruta-7-dias-marruecos/)github.com


(https://morocco-itinerary.com/es/tour/itinerario-de-7-dias-en-marruecos/)github.com


(https://morocco-itinerary.com/es/tour/viaje-de-8-dias-desde-tanger-en-marruecos/)github.com

(https://morocco-itinerary.com/es/tour/9-dias-en-marruecos/)github.com

(https://morocco-itinerary.com/es/tour/marruecos-10-dias-desde-tanger/)github.com

(https://morocco-itinerary.com/es/tour/10-dias-de-vacaciones-en-marruecos/)github.com

(https://morocco-itinerary.com/es/tour/marruecos-11-dias-desde-tanger/)github.com

(https://morocco-itinerary.com/es/tour/marruecos-en-12-dias/)github.com


(https://morocco-itinerary.com/es/marruecos-viajes/)github.com


(https://morocco-itinerary.com/es/terminos-condiciones/)github.com

(https://morocco-itinerary.com/es/sobre-nosotros-el-equipo/)github.com

(https://morocco-itinerary.com/es/resenas/)github.com

(https://morocco-itinerary.com/es/resenas/)github.com

(https://morocco-itinerary.com/es/tour-destination/tanger-es/)github.com

(https://morocco-itinerary.com/es/tour-destination/marrakech-es/)github.com

(https://morocco-itinerary.com/es/tour-destination/fez-es/)github.com

(https://morocco-itinerary.com/es/tour-destination/casablanca-es/)github.com

(https://morocco-itinerary.com/es/marruecos-viajes/contacto/contacto-1/)github.com

(https://morocco-itinerary.com/es/marruecos-viajes/)github.com

(https://morocco-itinerary.com/)github.com

(https://morocco-itinerary.com/who-we-are/)github.com

(https://morocco-itinerary.com/reviews/)github.com

(https://morocco-itinerary.com/contact-2/)github.com

(https://morocco-itinerary.com/terms-conditions/)github.com

(https://morocco-itinerary.com/morocco-tours-packages-2/)github.com

(https://morocco-itinerary.com/can-i-travel-to-morocco-from-usa/)github.com

(https://morocco-itinerary.com/are-4-or-5-or-7-or-10-days-enough-in-morocco/)github.com

(https://morocco-itinerary.com/what-to-do-in-morocco-for-1-week/)github.com

(https://morocco-itinerary.com/morocco-travel-itinerary-5-days/)github.com

(https://morocco-itinerary.com/moroccan-tour-morocco-trips/)github.com

(https://morocco-itinerary.com/whats-morocco-flag-history/)github.com

(https://morocco-itinerary.com/tour/full-day-tour-from-marrakech-to-ait-benhaddou-kasbah/)github.com

(https://morocco-itinerary.com/tour/private-1-day-excursion-to-essaouira-from-marrakech/)github.com

(https://morocco-itinerary.com/tour/private-1-day-excursion-to-imlil-from-marrakech/)github.com

(https://morocco-itinerary.com/tour/1-day-trip-to-ouzoud-waterfalls/)github.com

(https://morocco-itinerary.com/merzouga-quad-biking-around-desert/)github.com

(https://morocco-itinerary.com/tour-destination/tangier/)github.com

(https://morocco-itinerary.com/tour-destination/marrakech/)github.com

(https://morocco-itinerary.com/tour-destination/fes/)github.com

(https://morocco-itinerary.com/tour/)github.com

(https://morocco-itinerary.com/tour-destination/casablanca/)github.com

(https://morocco-itinerary.com/who-we-are/)github.com

(https://morocco-itinerary.com/reviews/)github.com

(https://morocco-itinerary.com/contact-2/)github.com

(https://morocco-itinerary.com/terms-conditions/)github.com

(https://morocco-itinerary.com/hsb/marokko-reise/)github.com

(https://morocco-itinerary.com/hsb/uber-uns-team/)github.com

(https://morocco-itinerary.com/hsb/marokko-reise/kontakt/)github.com

(https://morocco-itinerary.com/hsb/bewertungen/)github.com

(https://morocco-itinerary.com/hsb/tour-destination/tanger/)github.com

(https://morocco-itinerary.com/hsb/tour-destination/marrakesch/)github.com

(https://morocco-itinerary.com/hsb/tour-destination/fes-hsb/)github.com

(https://morocco-itinerary.com/hsb/tour-destination/casablanca-hsb/)github.com

(https://morocco-itinerary.com/it/casa/viaggi-in-marocco/)github.com

(https://morocco-itinerary.com/it/chi-siamo-il-team/)github.com

(https://morocco-itinerary.com/it/itinerario-di-10-giorni-in-marocco/)github.com

(https://morocco-itinerary.com/it/tour-individuale-7-giorni-in-marocco/)github.com

(https://morocco-itinerary.com/it/tour-marocco-9-giorni/)github.com

(https://morocco-itinerary.com/it/viaggio-in-marocco-5-giorni/)github.com

(https://morocco-itinerary.com/it/casa/contattateci/)github.com

(https://morocco-itinerary.com/it/recensioni/)github.com

(https://morocco-itinerary.com/it/tour-destination/tanger-it/)github.com

(https://morocco-itinerary.com/it/tour-destination/marrakech-it/)github.com

(https://morocco-itinerary.com/it/tour-destination/fez-2/)github.com

(https://morocco-itinerary.com/it/tour-destination/casablanca-it/)github.com

(https://morocco-itinerary.com/it/tour/)github.com
 [2023-06-30 10:02 UTC] julia788maxwell at gmail dot com
great info (https://github.com/.php)(https://www.yourtexasbenefits.bid/)
 [2024-07-10 05:18 UTC] jeffrey597doss at outlook dot com
Thank you for posting that it could be just the thing to give inspiration to someone who needs it! Keep up the great work!  (https://github.com)(https://www.summithealth-patientportal.com)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 25 08:01:32 2024 UTC