fix: memory-leak due to unbound type-parameter recursion - #112
Merged
pfitzseb merged 2 commits intoJul 6, 2026
Merged
Conversation
FakeTypeName expanded a type's parameters recursively with no size bound. A few types explode into enormous trees: type-domain packages whose types recurse into themselves (e.g. TypeDomainNaturalNumbers — naturals as nested types, rationals as continued fractions), and even some Base/LinearAlgebra signatures whose `where`-bounded `Union`s reach tens of thousands of nodes. This produced multi-gigabyte cache files (2.2 GB for TypeDomainNaturalNumbers) that exhausted memory — OOMing the machine — when read back into the store. Cap expansion with a per-type budget of expanded DataTypes (MAX_EXPANDED_TYPES = 128): once it is spent, a type's remaining parameters are dropped and only its name is kept. The budget bounds any shape of explosion (depth, width, or indirect recursion through variable bounds), while ordinary types stay far below it and are unaffected. Add a regression test. Ported from julia-vscode/SymbolServer.jl#320 (SymbolServer.jl is deprecated; the code now lives here under shared/symbolserver/).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #112 +/- ##
=======================================
Coverage 0.00% 0.00%
=======================================
Files 15 56 +41
Lines 682 7382 +6700
=======================================
- Misses 682 7382 +6700
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
Is this still required with #108? If yes, would be nice to also emit a Re |
…ntinel
Instead of silently dropping all parameters when the ExpandBudget is
spent, keep the type's name and a single Unserializable() parameter, so
truncated types render as Foo{…} instead of a misleadingly bare Foo.
Budget is now only spent on types that actually have parameters, and
bumped to 256 to clear the p99 of Base/stdlib signature slots (~160
expanded DataTypes) with some margin.
The sentinel needs a writer method to roundtrip: without one, a
parameters vector containing it would MethodError during the cache
write and degrade the whole module binding to Unserializable.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
FakeTypeNameexpanded a type's parameters recursively with no size bound. A few types explode into enormous trees: type-domain packages whose types recurse into themselves (e.g.TypeDomainNaturalNumbers— naturals as nested types, rationals as continued fractions), and even someBase/LinearAlgebrasignatures whosewhere-boundedUnions reach tens of thousands of nodes. This produced multi-gigabyte cache files (2.2 GB forTypeDomainNaturalNumbers) that exhausted memory — OOMing the machine — when read back into the store.Cap expansion with a per-type budget of expanded
DataTypes (MAX_EXPANDED_TYPES = 128): once it is spent, a type's remaining parameters are dropped and only its name is kept. The budget bounds any shape of explosion (depth, width, or indirect recursion through variable bounds), while ordinary types stay far below it and are unaffected.Ported from julia-vscode/SymbolServer.jl#320 (SymbolServer.jl is deprecated; the code now lives here under shared/symbolserver/).