mirror of
https://github.com/google/brotli.git
synced 2026-07-08 17:56:58 +00:00
BrotliEncoderSetCustomDictionary() causes "false" OOM #154
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ralfjunker on GitHub (Jan 31, 2017).
In the code below,
BrotliEncoderSetCustomDictionary()causes a "false" OOM on compression, which causes the application to halt. Curiously, the OOM is not a real OOM. It only appears as such as a result ofmalloc(0)which returnsNULL.Without the
BrotliEncoderSetCustomDictionary()call all works fine.The OOM happens in
BrotliSplitBlock(), fileblock_splitter.con line 137:https://github.com/google/brotli/blob/master/enc/block_splitter.c#L137
I hope you can reproduce the issue. If you have questions, please let me know.
@eustas commented on GitHub (Feb 1, 2017):
Hello.
Thanks for the report, going to fix it ASAP.
NB: exit on OOM is considered normal for code in production; use
-DBROTLI_ENCODER_CLEANUP_ON_OOMcompiler option to allow encoder finish its work and cleanup after itself.@ralfjunker commented on GitHub (Feb 1, 2017):
You are correct in saying that
-DBROTLI_ENCODER_CLEANUP_ON_OOMworks around the exit. However, compression still fails andBrotliEncoderCompressStream()returnsBROTLI_FALSE.Here is a solution I found to pass my tests: Don't call
BROTLI_ALLOCifliterals_countis0. It's a small change to https://github.com/google/brotli/blob/master/enc/block_splitter.c#L137, just replacewith