crash inside brotli::BrotliCompressor::WriteBrotliData() #106

Closed
opened 2026-01-29 20:34:57 +00:00 by claunia · 2 comments
Owner

Originally created by @nitram509 on GitHub (May 16, 2016).

Abstract

When doing compression, using the WriteBrotliData() 3-times in a row, the program will crash.

Hint:
the argument for 'is_last' is always 'true'. Setting this argument to false, will "fix" this crash.

Expected behavior

Even if I use is_last=true multiple times, I expect no crashes.
Instances of BrotliCompressor should maintain a "safe" internal state
and should not crash.

Example program, which crashes:

https://gist.github.com/nitram509/081b5826e173910eba20097cba9dde8c

Environment

The program crashes on these environments

  • Windows 10, 64bit, MinGW-w64 v3.4, GCC v4.9.2
  • Windows 10, 64bit, Visual C++ 2015 Update v2
  • Ubuntu Linux, 64bit, GCC v4.9.2-10

The program will NOT crash on OSX, even when doing 100x WriteBrotliData().

  • OSX (latest), 64bit, LLVM v7.3.0, clang-703.0.31

Background information

I'm the author of jbrotli (Java bindings for (lib-)brotli).
A user of jbrotli filled an issue and it seems to me, there is a bug inside brotli itself.
So I wrote a minimal C-program to demonstrate, what's going on inside the Java-program.

Originally created by @nitram509 on GitHub (May 16, 2016). ## Abstract When doing compression, using the WriteBrotliData() 3-times in a row, the program will crash. Hint: the argument for 'is_last' is always 'true'. Setting this argument to false, will "fix" this crash. ### Expected behavior Even if I use is_last=true multiple times, I expect no crashes. Instances of BrotliCompressor should maintain a "safe" internal state and should not crash. ## Example program, which crashes: https://gist.github.com/nitram509/081b5826e173910eba20097cba9dde8c ## Environment The program crashes on these environments - Windows 10, 64bit, MinGW-w64 v3.4, GCC v4.9.2 - Windows 10, 64bit, Visual C++ 2015 Update v2 - Ubuntu Linux, 64bit, GCC v4.9.2-10 The program will NOT crash on OSX, even when doing 100x WriteBrotliData(). - OSX (latest), 64bit, LLVM v7.3.0, clang-703.0.31 ## Background information I'm the author of jbrotli (Java bindings for (lib-)brotli). A user of jbrotli filled an issue and it seems to me, there is a bug inside brotli itself. So I wrote a minimal C-program to demonstrate, what's going on inside the Java-program.
Author
Owner

@eustas commented on GitHub (May 17, 2016):

Hello.

Thank you for your report. Going to fix problem ASAP.
Meanwhile we're preparing update to encoder that will bring more clear C streaming API.

Best regards,
Eugene.

@eustas commented on GitHub (May 17, 2016): Hello. Thank you for your report. Going to fix problem ASAP. Meanwhile we're preparing update to encoder that will bring more clear C streaming API. Best regards, Eugene.
Author
Owner

@nitram509 commented on GitHub (May 17, 2016):

👍

@nitram509 commented on GitHub (May 17, 2016): :+1:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#106