Avoid retaining parameter tables for invalid content types - #309
Merged
ringabout merged 1 commit intoAug 19, 2026
Merged
Conversation
Member
|
Thank you! The leak is probably related to nim-lang/Nim#26094 |
Contributor
Author
|
Thanks, that issue matches the behavior I observed very closely. This change should also provide a small defensive workaround for existing Nim releases while #26100 is being integrated. Thank you for working on the compiler-side fix! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ValueErrorbehavior for empty and malformed media types.Why
Prologue calls
parseContentType("")for requests without a Content-Type header. The parser previously allocated the parameter table before validating the media type and raisingValueError.In a persistent Prologue server, those allocations remained live during server operation and grew linearly with the request count. Valgrind reported no definitely-lost blocks at process exit, so this is runtime retention rather than an unreachable shutdown leak. It can still exhaust memory in a long-running server.
Massif attributed about 13.27 MiB of a 13.6 MiB live heap after approximately 5,200 requests to the table initialized in
parseContentType. With this change, the measured peak was about 0.33 MiB.In non-Valgrind runs with one concurrent persistent Joubako client:
Validation
This addresses a reproducible contributor to the memory growth reported in #305. The original 700-concurrency reproducer may still have additional contributing factors.