#1 2018-02-15 14:53:59

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,076
Website

Need help - SynZip fails on FPC(trunc) Win64 target

@hnb @ab
I'm found a case SynZip SOMETIMES fail to uncompress http response under FPC win64 (delphi if OK, fpc/Linux64 is OK).
After many attempts I'm reproduce situation in debug mode and dump a wrong gzipped file can be downloaded here (266 bytes)
The test case:

program Project1;
{$mode DELPHI}{$H+}
{$I Synopse.inc}
uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes,
  SynZip,
  SynCommons;

var
    s: RawByteString;
    a: AnsiString;
begin
   s := StringFromFile('wrong.gzip');
   a := CompressGZip(s, false);
end.

Result: Error -5 during uncompress mem

Error is raised inside paszlib/src/zinflate unit (inlined) and I'm not understand how to catch it
So I ask for a HELP

P.S. 99% of requests uncompressed well

Offline

#2 2018-02-15 15:45:09

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 11,693
Website

Re: Need help - SynZip fails on FPC(trunc) Win64 target

This is a FPC zlib bug...

Offline

#3 2018-02-15 19:12:13

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,076
Website

Re: Need help - SynZip fails on FPC(trunc) Win64 target

OK, when let's use a SynZLibSSE by default for FPC/Win64 target? At last all my integration test is passed in this case. I create a pull request 82

Offline

#4 2018-02-15 23:26:53

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 11,693
Website

Re: Need help - SynZip fails on FPC(trunc) Win64 target

SynZLibSSE is only for SSE4 cpus if I remember correctly.

Offline

#5 2018-02-16 06:41:48

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,076
Website

Re: Need help - SynZip fails on FPC(trunc) Win64 target

Yes, but this mean all Intel Core i3 and UP (2010) & AMD Opteron and UP (2011). If we spoke about windows x64 target - almost all computers.
In any case IMHO better that it does not work at all than does not work stably.
This bug is really critical for me, because it depends on user input. User enter something on form (in browser), browser gzip request and server can't unzip it

Last edited by mpv (2018-02-16 06:55:41)

Offline

#6 2018-02-16 07:24:02

hnb
Member
Registered: 2015-06-15
Posts: 291

Re: Need help - SynZip fails on FPC(trunc) Win64 target

ab wrote:

This is a FPC zlib bug...

maybe is worth to report this on FPC mantis bug tracker?


best regards,
Maciej Izak

Offline

#7 2018-02-16 08:27:56

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,076
Website

Re: Need help - SynZip fails on FPC(trunc) Win64 target

I check without SynZip - all work without errors. So problem in SynZip. I continue debugging

Offline

#8 2018-02-16 08:49:48

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 11,693
Website

Re: Need help - SynZip fails on FPC(trunc) Win64 target

Or we may just supply the "standard" .o files for FPC on both Win32 and Win64, just like with Delphi.

Offline

#9 2018-02-16 09:24:39

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,076
Website

Re: Need help - SynZip fails on FPC(trunc) Win64 target

Catch it! See fix
USEZLIBSSE returned back to original version(commented)
Also I add a small ifndef to not redefine a ZLIB_VERSION  from zbase

Offline

#10 2018-02-18 16:57:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 11,693
Website

Re: Need help - SynZip fails on FPC(trunc) Win64 target

Offline

#11 2018-02-18 18:37:54

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,076
Website

Re: Need help - SynZip fails on FPC(trunc) Win64 target

I found some problems with this commit (can't even compile to verify):
1) Unicode Delphi (Win32) PtrUInt defined twice with a different declaration - once SynCrtSock:348 (PtrUInt = cardinal), second SynZip:275 (PtrUInt = NativeUInt)
2) FPC Win64. If USEZLIBSSE defined - folder fpc-win64/sse is missing (please, add it to github). If not defined - I got the strange compiler errors: "Error: Undefined symbol: memcpy" (and the same about memset, malloc, free)

Last edited by mpv (2018-02-18 18:44:19)

Offline

#12 2018-02-18 21:20:18

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 11,693
Website

Re: Need help - SynZip fails on FPC(trunc) Win64 target

The missing files were added to the official sqlite3fpc.7z but you are right: I didn't add them to github.

Please also check https://synopse.info/fossil/info/8b8cf321c5

Offline

#13 2018-02-18 22:37:20

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,076
Website

Re: Need help - SynZip fails on FPC(trunc) Win64 target

Delphi win32 is Ok now - thanks!
But FPC win64 fails with Undefined symbol: memcpy (memset, malloc, free) even for a program from the first topic post with USEZLIBSSE and without USEZLIBSSE. Either something wrong with FPC linker of with *.o files or with defines. Even don't know where to start...

Offline

#14 2018-02-18 23:40:07

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 11,693
Website

Re: Need help - SynZip fails on FPC(trunc) Win64 target

Offline

#15 2018-02-19 08:19:22

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,076
Website

Re: Need help - SynZip fails on FPC(trunc) Win64 target

I checked the following cases: Delphi(XE2) Win32; FPC(trunc) Linux64 w/o USEZLIBSSE; FPC(trunc) win64 with and without USEZLIBSSE; All works. Many-many thanks for your work!

Offline

Board footer

Powered by FluxBB