octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #55427] save -v7 exits with "error compressing


From: A.R. Burgers
Subject: [Octave-bug-tracker] [bug #55427] save -v7 exits with "error compressing data element"
Date: Thu, 1 Jul 2021 03:49:39 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36 Edg/91.0.864.41

Follow-up Comment #9, bug #55427 (project octave):

don't know if it helps, but this stand-alone program reproduces the issue.


#include <string>                                                             
 
#include <iostream>                                                           
 
#include <random>                                                             
 
#include <zlib.h>                                                             
 

int main(int argc, char *argv[])
{                               
  int n_mega = 200;             
  size_t startLen = n_mega * 1024 * 1024;
  std::string buf_str(startLen, 'x');    
  uLongf srcLen = buf_str.length();      
  uLongf destLen = srcLen * 101 / 100 + 12;
  char * out_buf = new char[destLen];

  if (1) {
    // make buf_str more difficult to compress by
    // filling it with random numbers
    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_int_distribution <unsigned char> distrib(1, 116);

    for (size_t n = 0; n < startLen; ++n) {
      buf_str[n] = distrib(gen);
    }
  }

  std::cout << "srcLen=" << srcLen << " destLen=" << destLen << std::endl;

  int retval = compress (reinterpret_cast       <Bytef *> (out_buf),       
&destLen,
                         reinterpret_cast <const Bytef *> (buf_str.c_str()),
srcLen);
  if (retval != Z_OK) {
    std::cerr << "save: error compressing data element. retval=" << retval <<
std::endl;
    return 0;
  }
  std::cout << "after compression: destLen=" << destLen << std::endl;

  return 0;
}


this is the output from the mingw64 console with the error code:


$ g++ -o zz zz.cc -lz
$ ./zz
srcLen=209715200 destLen=40013672
save: error compressing data element. retval=-5


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?55427>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]