Tcl Source Code

View Ticket
Login
Ticket UUID: 8af92dfb668b292a7b21df9ac0418e3bc2e68be
Title: zlib transform issue, bad inflate
Type: Bug Version: 8.7a4, 8.6.10, 8.6.7, ...
Submitter: aku Created on: 2020-04-14 20:03:17
Subsystem: 57. zlib Assigned To: dkf
Priority: 5 Medium Severity: Critical
Status: Closed Last Modified: 2020-04-16 05:46:10
Resolution: Fixed Closed By: aku
    Closed on: 2020-04-16 05:46:10
Description:

I have an example file (591 bytes) where inflation using a channel transform generates a file which is 3096 bytes short of the actual file it was generated from by deflation. Using direct in-memory inflation OTOH is ok, i.e. reconstructs the input correctly (size, and sha256sum). I have not tried to use a stream object.

Example file and test script will be attached.

Output from the example run

  hephaistos:(529) ~/Play/CoreSources/B > tclsh example.tcl 
  ./example.direct:    458752
  ./example.transform: 455656
  Transform under by 3096, vs direct
I have seen this issue with 8.6.7 first, then confirmed to be still present in 8.6.10, and 8.7a4 (commit [c92d723731] on core-8-branch).

User Comments: aku added on 2020-04-16 05:46:10:
Followup: Ticket [f70ce1feadf55c2f0fd142bdc20fbdcae5698495].

aku added on 2020-04-16 04:25:21:

I confirm that commit [96e1e0251b] fixes the ticket:

hephaistos:(510) ~/Play/CoreSources/B/tcl > tclsh ../example.tcl 
../example.direct:    458752
../example.transform: 458752
Match

... And `make test` passes.


sebres added on 2020-04-15 19:14:05:

Check-in [96e1e0251b] fixes this, but...

The whole handling around ZlibTransformInput is very strange:

- ZlibTransformInput reads an input buffer for inflate in single bytes (where it can do that in larger chunks), so the internal cycle (e.g. callback execution) repeated toooooo many times;
- ResultGenerate/ResultCopy doing to many copy operations (ResultGenerate could decode to next (required) part of decompression buffer directly so ResultCopy could obtain the buffer without interim copy operations here and there.
- etc;


Attachments: