Compression fails in Adler32 on a machine that supports SSE3, but not SSSE3 #511

Open
opened 2026-01-29 22:13:07 +00:00 by claunia · 0 comments
Owner

Originally created by @emz00 on GitHub (Mar 30, 2022).

We're using MongoDB.Driver, which indirectly calls SharpCompress and it fails on a machine with a AMD Opteron(tm) Processor 6176 SE CPU, which supports SSE3, but not SSSE3.

System.PlatformNotSupportedException: Operation is not supported on this platform.
   at System.Runtime.Intrinsics.X86.Ssse3.MultiplyAddAdjacent(Vector128`1 left, Vector128`1 right)
   at SharpCompress.Algorithms.Adler32.CalculateSse(UInt32 adler, ReadOnlySpan`1 buffer)
   at SharpCompress.Algorithms.Adler32.Calculate(UInt32 adler, ReadOnlySpan`1 buffer)
   at SharpCompress.Compressors.Deflate.ZlibCodec.read_buf(Byte[] buf, Int32 start, Int32 size)
   at SharpCompress.Compressors.Deflate.DeflateManager._fillWindow()
   at SharpCompress.Compressors.Deflate.DeflateManager.DeflateSlow(FlushType flush)
   at SharpCompress.Compressors.Deflate.DeflateManager.Deflate(FlushType flush)
   at SharpCompress.Compressors.Deflate.ZlibBaseStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at MongoDB.Bson.IO.ByteBufferStream.EfficientCopyTo(Stream destination)

This seems to be because the version of Adler32 used by SharpCompress checks for SSE3 and then uses SSSE3:

            if (Sse3.IsSupported && buffer.Length >= MinBufferSize)
            {
                return CalculateSse(adler, buffer); // using SSSE3
            }

This is already fixed in the latest version: https://github.com/SixLabors/ImageSharp/blob/main/src/ImageSharp/Compression/Zlib/Adler32.cs

That checks Ssse3.IsSupported - could you please upgrade to it? That would also fix #645.

Originally created by @emz00 on GitHub (Mar 30, 2022). We're using MongoDB.Driver, which indirectly calls SharpCompress and it fails on a machine with a AMD Opteron(tm) Processor 6176 SE CPU, which supports SSE3, but not SSSE3. ``` System.PlatformNotSupportedException: Operation is not supported on this platform. at System.Runtime.Intrinsics.X86.Ssse3.MultiplyAddAdjacent(Vector128`1 left, Vector128`1 right) at SharpCompress.Algorithms.Adler32.CalculateSse(UInt32 adler, ReadOnlySpan`1 buffer) at SharpCompress.Algorithms.Adler32.Calculate(UInt32 adler, ReadOnlySpan`1 buffer) at SharpCompress.Compressors.Deflate.ZlibCodec.read_buf(Byte[] buf, Int32 start, Int32 size) at SharpCompress.Compressors.Deflate.DeflateManager._fillWindow() at SharpCompress.Compressors.Deflate.DeflateManager.DeflateSlow(FlushType flush) at SharpCompress.Compressors.Deflate.DeflateManager.Deflate(FlushType flush) at SharpCompress.Compressors.Deflate.ZlibBaseStream.Write(Byte[] buffer, Int32 offset, Int32 count) at MongoDB.Bson.IO.ByteBufferStream.EfficientCopyTo(Stream destination) ``` This seems to be because the version of Adler32 used by SharpCompress checks for SSE3 and then uses SSSE3: ``` if (Sse3.IsSupported && buffer.Length >= MinBufferSize) { return CalculateSse(adler, buffer); // using SSSE3 } ``` This is already fixed in the latest version: https://github.com/SixLabors/ImageSharp/blob/main/src/ImageSharp/Compression/Zlib/Adler32.cs That checks `Ssse3.IsSupported` - could you please upgrade to it? That would also fix #645.
claunia added the bugup for grabs labels 2026-01-29 22:13:07 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#511