Skip to content

zlib different on OSX and Linux in newest releases #12244

Closed
@flippmoke

Description

@flippmoke

It appears that after #10980, there are some issues with zlib specifically producing different results on OSX during gzip compression. This can be reproduced by the small test below, where there is a single byte difference in the zlib results. This same test does not produce different then expected results on Linux.

var zlib = require('zlib');

var uncompressed = Buffer.from("1ad40178020a05776f726c642880201a0441524541220420b8f3371a044649505322040a0255531a0449534f321a0449534f3322050a035553411a034c4154220919560e2db29dcf43401a034c4f4e220919105839b4c8a658c01a044e414d45220f0a0d556e69746564205374617465731a07504f5032303035220620b196fd8e011a06524547494f4e220220131a09535542524547494f4e220220151a02554e220320c806122f18032210098042ff011a008044ff430000ff430f08cf01121600000101020103020403050406050706080709080a091ad50178020a06776f726c64322880201a0441524541220420b8f3371a044649505322040a0255531a0449534f321a0449534f3322050a035553411a034c4154220919560e2db29dcf43401a034c4f4e220919105839b4c8a658c01a044e414d45220f0a0d556e69746564205374617465731a07504f5032303035220620b196fd8e011a06524547494f4e220220131a09535542524547494f4e220220151a02554e220320c806122f18032210098042ff011a008044ff430000ff430f08cf01121600000101020103020403050406050706080709080a09", "hex");

var compressed = Buffer.from("1f8b080000000000000393bac258c1c4c55a9e5f9493a2d1a020c5e218e4eaa8c4a2b0e3b3b9148b9b6740b0120b175368b0148b67b0bf1198345662e5620e0d769462f6710c51e2940ce3d3dd34f7bcb30390efef07e40b44586e39b12ce280148b9fa3afab123f176f685e66496a8a42704962496ab1147b807f80918181a9129bc2c6697ffb18a5d8825cdd3d815a991484a53883439de05c5129a6503f256685136c42fa12cc4a029c0d4eff19a5181a5cfe3b3330fc77e6e738cf2824c6c0c0c8c8c4c8ccc4c2cccac2c6cacec6c1cec9c1c5297515e42d36b0b78c8691bf005ccccc9baf010000", "hex");

zlib.gzip(uncompressed, {strategy: zlib.Z_DEFAULT_STRATEGY}, function(err, buffer) {
    if (buffer.toString('hex') === compressed.toString('hex')) {
        console.log("Results are the same");
    } else {
        console.log("Results are different");
    }
});
  • Version: v4.8.1
  • Platform: OS-X
  • Output: Results are the same

  • Version: v4.8.1
  • Platform: Linux
  • Output: Results are the same

  • Version: v4.8.2
  • Platform: OS-X
  • Output: Results are different

  • Version: v4.8.2
  • Platform: Linux
  • Output: Results are the same

I believe this also affects the v6 latest release, but have not tested it yet.

Metadata

Metadata

Assignees

Labels

macosIssues and PRs related to the macOS platform / OSX.zlibIssues and PRs related to the zlib subsystem.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions