-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Large BTreeMap key or value types cause avoidable stack overflow #81444
Copy link
Copy link
Open
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
Activity
Metadata
Metadata
Assignees
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
I tried this code:
built with plain
rustcon 64 bit Windows (it happens in release code too but not with this example).I expected to see the program finishing silently.
Instead, this happened:
This becomes sporadic if you decrease the size of the key and disappears below 19540 bytes (on my system).
On my Linux box, and on playground, the size can be increased to somewhere between 160_000 and 170_000 bytes before the stack overflows.
rustc --version --verbose:This is not necessarily a bug, since there has to be some system-dependent limit. And it's not smart to inline big chunks of data as key or value, because usually about half of the key-value space allocated by BTreeMap remains unused. But the limit on Windows is much lower than I expected (and before #81494 can apparently easily be
liftedimproved by usingboxinstead ofBox::newfor the construction of btree nodes).