poco icon indicating copy to clipboard operation
poco copied to clipboard

"I/O Errror: Bad output stream" when compressing > 2GB of data.

Open PG-Devs opened this issue 6 years ago • 3 comments

Expected behavior

Be able to add more than 2GB of data to zip file.

Actual behavior

Poco.IOException: "I/O Errror: Bad output stream"

Steps to reproduce the problem

#include "stdafx.h"
#include <Poco/Zip/Compress.h>
#include <fstream>
#include <iostream>
#include <sstream>

int main(int /* unreferenced argc */, char* argv[])
{
	std::string path = argv[0];
	path = path.substr(0, path.rfind('\\'));

	// Prepare some random data
	srand(0);
	std::string data(256*1024*1024 /*256MB*/, char(0));
	for(int d = 0; d<data.size(); ++d)
		data[d] = char(rand());
	std::fstream dummy;
	dummy.open(path + "/dummy.bin", std::ios_base::out);
	dummy.write(data.data(), data.size());
	dummy.close();

	// Create zip
	try {
		std::stringstream output;
		//Poco::Zip::Compress zip(output, true, true); // I/O Error
		//Poco::Zip::Compress zip(output, false, true); // I/O Error
		//Poco::Zip::Compress zip(output, false, false); // I/O Error
		Poco::Zip::Compress zip(output, true, false); // I/O Error
		for (int i = 0 ; i < 32; ++i) {
			const std::string zippath = "some/path/file_" + std::to_string(i) + ".bin";
			std::cout << "Adding '" << zippath << "'\n";
			zip.addFile(path + "/dummy.bin", zippath, Poco::Zip::ZipCommon::CM_STORE);
		}
	}
	catch (const Poco::Exception& e) {
		std::cout << "Poco error: " << e.displayText() << "\n";
	}
	catch (const std::exception& e) {
		std::cout << "Error: " << e.what() << "\n";
	}

	return 0;
}

POCO version

poco-poco-1.9.0-release

Compiler and version

Microsoft (R) C/C++ Optimizing Compiler Version 19.20.27027.1 for x86

Operating system and version

Microsoft Windows [Version 10.0.17134.523]

Other relevant information

PG-Devs avatar Jan 22 '19 13:01 PG-Devs

Hi,

I am seeing the same issue when using DeflatingOutputStream with more than 2GB of data. It throws an exception when close() is called.

POCO Version: 1.9.0 Compiler: Visual Studio 15 (14.0.25431.01 Update 3) OS: Windows 10 Build: x64 release

I have repro code that I can post if it would be helpful.

not-sungard avatar Mar 05 '19 13:03 not-sungard

On second thoughts I'll raise mine as a separate issue.

not-sungard avatar Mar 07 '19 10:03 not-sungard

This issue is stale because it has been open for 365 days with no activity.

github-actions[bot] avatar Jun 22 '22 03:06 github-actions[bot]

This issue was closed because it has been inactive for 60 days since being marked as stale.

github-actions[bot] avatar Aug 21 '22 03:08 github-actions[bot]

probably related to #2590

aleks-f avatar Aug 21 '22 12:08 aleks-f