-
Notifications
You must be signed in to change notification settings - Fork 26
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
Zip files larger than 4GB fail on Windows #12
Comments
Hi @tuxan11, can you please make sure that you're up-to-date with the |
Hello @johnmaguire,
BTW, I will upload the zip created with this code to a fileshare and send you the link. |
@tuxan11 Thanks for the ZIP, I'll be looking into it as soon as possible. Just a couple more questions: You're not seeing any PHP errors or warnings in your log? Do you have output buffering turned off? Try adding this before your Zipstream code:
This will turn off output buffering if it's turned on. If you're using a framework like Kohana, Laravel, or CodeIgniter, it's quite likely that it starts buffering prior to your code getting executed. This can cause out of memory issues. Thanks! |
Hello John, |
@tuxan11 There's one more thing I'll ask you to try if that doesn't work for you... if you look at this issue you can see that @ianvonholt had some issues using the streaming capabilities of the library after we switched our code from using If so, I can target a single bug instead of two. :) Thanks! |
@johnmaguire I did try that solution yesterday(but the result was same) as I was browsing through the issue list. |
@johnmaguire I tried with explicit memory buffer off and still the same issue. Please let me know if you want me try anything different. |
@tuxan11 Thanks for giving it a shot. I should have asked sooner -- can I get the PHP version, distro version, and web server version? Also, does this issue occur with files full of just |
@johnmaguire Here is the info: This problem occurs with any files. I just created bunch of files using linux command and zipped them up. |
@johnmaguire, were you able to find any issues with the zip file that I uploaded ? |
@tuxan11 It definitely doesn't look correct. :) I'm hoping to get a tool from a colleague of mine that analyzes ZIP files to see exactly what's off. I'm also creating a test to reproduce this: -> % cat issue_12.php
<?php
// Github issue: https://github.com/barracudanetworks/ArchiveStream-php/issues/12
// ZIPs with a size exceeding 4 GB are corrupt
require_once './ArchiveStream-php/stream.php';
require_once './ArchiveStream-php/zipstream.php';
$files = array(
'A.bin', // 2.5GB
'B.bin', // 2.5GB
);
$opt = array(
'comment' => 'Hello world',
);
$zip = new \ArchiveStream_Zip('download.zip');
foreach ($files as $file)
{
$fh = fopen($file, 'r');
$stat = fstat($fh, $stat['size'], $opt);
while (!feof($fh))
{
$zip->init_file_stream_transfer(fread($fh, 1024 * 1024));
}
}
$zip->complete_file_stream();
$zip->finish(); If I can't reproduce with this script, I'll attempt one using a single 5GB file to see if that creates a corrupt ZIP. Also, did you have a comment on your ZIP file that reads "Generated by FileCloud"? I don't see this in the sample code you provided. If so, I think the code that adds a comment to the ZIP file may be a little messed up. If not, you're outputting more to the page than simply the ZIP file, and that could be part of your issue. |
Looks like that reproduced it. Will look into this after lunch hopefully.
|
Err, scratch that, my script was totally messed up, haha. Going to give it another go with this: -> % cat issue_12.php
<?php
// Github issue: https://github.com/barracudanetworks/ArchiveStream-php/issues/12
// ZIPs with a size exceeding 4 GB are corrupt
ini_set('max_execution_time', 0);
require_once './ArchiveStream-php/stream.php';
require_once './ArchiveStream-php/zipstream.php';
$files = array(
'A.bin',
'B.bin',
);
$opt = array(
'comment' => 'Hello world',
);
$zip = new \ArchiveStream_Zip('issue_12.zip');
foreach ($files as $file)
{
// Note: Using stat instead of fstat
$fh = fopen($file, 'r');
$zip->init_file_stream_transfer($file, $stat['size'], $opt);
while (!feof($fh))
{
$zip->stream_file_part(fread($fh, 1024 * 1024));
}
$zip->complete_file_stream();
}
$zip->finish(); |
That seemed to work just fine:
Some info about the server used to produce the zip file:
Could you try running the script I posted above? To generate A.bin and B.bin, I used the following commands on Linux:
Any data should do. |
One last note for now... I added $opt into the ArchiveStream_Zip constructor, in order to make sure ZIP file-level comments work. No problems:
|
@johnmaguire, thanks for the info. I will try to run the script and get back to you. |
@johnmaguire I tried your code on my windows box and it resulted in a corrupted zip same as before. |
Hi tuxan11. I don’t have any Windows machines currently, nor do we use any here at Barracuda Networks. If I get some time over the next week or so, I’ll try to setup a VM to test this in. No guarantees. :( Just to verify, do you have the GMP PHP extension installed correctly? John
|
Also, when testing on Linux, did you use Apache? If so, version used there
|
@johnmaguire, on Linux I used Apache version: 2.2.15. |
Thanks! I'm able to reproduce this in a Windows VM with the latest XAMPP using PHP 5.5. I'll try to debug this soon. :) |
Any news about this? I have been trying all day to make this work with files larger than 4GB. |
Are you saying that if you switch from Found this on php.net/filesize: Definitely sounds like it could be related. Thank you for the information. I haven't tracked down the problem yet, but the PHP warning and that info is definitely helpful! Also, are you using an up-to-date version of the ArchiveStream library? Line 361 of stream.php doesn't seem to be a |
On Windows, the sizes of large files (>2GB on 32bit systems and >4GB on 64bit) will always be reported incorrect by "filesize()". Regardless of fixing this problem, the library still provides corrupt archives. I know that line doesn't specifically use any GMP functions, but the error points always to the "$low = $value & $right;" line. I have found however that this error occurs only with PHP 5.6, so I will skip that version for now. |
Interesting. Thanks again for all the info.
|
Note: on windows before PHP 7 there is no support for 64 bit integers, even if running php 64 bit. For this reason filesize() function reports negative value for files > 2GB. // Check if PHP is running with 64 bit integer support
if (PHP_INT_SIZE < 8) {
// NOT 64 bit
} |
@FabryB I believe that is what @vvllaadd was saying above. He switched out the Thank you for the information. |
[0.2.0] Add PHP 7.3 to the matrix, drop PHP 5.4, 5.5, 5.6, 7.0
Hello,
Thanks for this great library. I am able to integrate this with a project that I am working on. The library creates downloadable zips perfectly when the entire zip file size is under 4GB. However, once the zip file size exceeds 4GB, the downloaded zip is not usable anymore. Unzip utilities complain that it is an corrupted zip.
Some more details of the issue:
Format used: Zip
No of files used : 10 (each file averaging about 500MB)
Total zip size: about 4.6 GB
Unzip utilities tried (and failed): Windows default, winzip and ALZip
Can you please let me know if I am missing something or this is a know limitation of the library.
The text was updated successfully, but these errors were encountered: