Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-11

paszlib problem: integer overflow

6 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Dennis Poon

I downloaded the Paszlib-sg from http://sagsehome.net/oss/paszlib-sg.php (as suggested by Paszlib freepascal.org wiki).

I works fine on my Delphi 5 until I try to compress a file with size of 70M and it raises the exception of integer flow error.

Does anyone have this problem?

I initially thought it might be a Delphi 5 problem so I tried to use Lazarus with fpc 2.6.2 to compile the same problem but it kept complaining cannot find zstream although I already add FCL package to the required packages list.

Please help.

Dennis

Reply by email

Dennis Poon
to Dennis Poon
Dennis Poon wrote 18 lines
I downloaded the Paszlib-sg from http://sagsehome.net/oss/paszlib-sg.php (as suggested by Paszlib freepascal.org wiki). I works fine on my Delphi 5 until I try to compress a file with size of 70M and it raises the exception of integer flow error. Does anyone have this problem? I initially thought it might be a Delphi 5 problem so I tried to use Lazarus with fpc 2.6.2 to compile the same problem but it kept complaining cannot find zstream although I already add FCL package to the required packages list. Please help. Dennis

I found the bug, it is in zDeflat.pas
procedure fill_window

line 1595:

   Dec(s.match_start, wsize) ; //which gives integer underflow as

s.match_start is < wsize and both paramters are defined as unit

When the file to compress is > 30M in size

I am ok to avoid compressing any file that big but I just worried that this bug might happen in other situations as well.

Is anyone else using this paszlib?

Dennis

Reply by email

Marco van de Voort
to Dennis Poon: I found the bug, it is in zDeflat.pas procedure fill_window line 1595:…

In our previous episode, Dennis Poon said:

Dennis Poon wrote: > I downloaded the Paszlib-sg from > http://sagsehome.net/oss/paszlib-sg.php (as suggested by Paszlib > freepascal.org wiki).

No. It doesn't suggest that. It says that code in FPC originally came from the same sources as that. But paszlib in FPC has had bugfixes.

> I works fine on my Delphi 5 until I try to compress a file with size > of 70M and it raises the exception of integer flow error.

That means you enabled that somehow. Integer under/overflow is generally not enabled by default, and it is somewhat unlogical to use it with converted C code.

> I initially thought it might be a Delphi 5 problem so I tried to use > Lazarus with fpc 2.6.2 to compile the same problem but it kept > complaining cannot find zstream although I already add FCL package to > the required packages list.

Probably cause by providing external paszlib sources, in combination with precompiled already there paszlib sources, the compiler gets confused what depends on what.

Forget about the -sg code for Lazarus, simply use the FPC provided one only. Turn off the range checks, and try again.

Reply by email

Dennis Poon
to Marco van de Voort

I works fine on my Delphi 5 until I try to compress a file with size

Show quoted text 20 lines
>> of 70M and it raises the exception of integer flow error. >> That means you enabled that somehow. Integer under/overflow is generally not enabled by default, and it is somewhat unlogical to use it with converted C code. >> I initially thought it might be a Delphi 5 problem so I tried to use >> Lazarus with fpc 2.6.2 to compile the same problem but it kept >> complaining cannot find zstream although I already add FCL package to >> the required packages list. >> Probably cause by providing external paszlib sources, in combination with precompiled already there paszlib sources, the compiler gets confused what depends on what. Forget about the -sg code for Lazarus, simply use the FPC provided one only. Turn off the range checks, and try again.

I'd love to just use the paszlib in Lazarus/fpc but I also need the same unit for Delphi 5 (Dephi 5 program will compress data and send to linux /lazarus/fpc program ) so both sides need to understand the same compress/decompress protocol.
I tried using the lazarus/fpc paszlib unit in Dephi 5 but it does not compile. Too many errors.
The paszlib-sg is the only pascal unit that produces compressed data readable by FPC's zstream and zipper units.

:-(

Dennis

Reply by email

José Mejuto
to Dennis Poon
Dennis Poon wrote 9 lines
I'd love to just use the paszlib in Lazarus/fpc but I also need the same unit for Delphi 5 (Dephi 5 program will compress data and send to linux /lazarus/fpc program ) so both sides need to understand the same compress/decompress protocol. I tried using the lazarus/fpc paszlib unit in Dephi 5 but it does not compile. Too many errors. The paszlib-sg is the only pascal unit that produces compressed data readable by FPC's zstream and zipper units.

Hello,

Both paszlib implementation are very, very similar, so try to spot the differences. Also are you trying to compress the 70 MB in one shot ? Post a piece of code that works by itself (just compiles) but that fail with >70 MB files.

Reply by email