about summary refs log tree commit diff
path: root/src/libsyntax/errors
diff options
context:
space:
mode:
authorAndrew Paseltiner <apaseltiner@gmail.com>2015-09-18 14:15:02 -0400
committerAndrew Paseltiner <apaseltiner@gmail.com>2015-09-18 15:27:17 -0400
commit9526813f5bc088261201934d7d6e574231eb252e (patch)
treeea5f2ec544a79fd5c49865a5d89c5fd6563c90d4 /src/libsyntax/errors
parentcff04117064ddee95f425c49f22c8aa5a3a665d4 (diff)
downloadrust-9526813f5bc088261201934d7d6e574231eb252e.tar.gz
rust-9526813f5bc088261201934d7d6e574231eb252e.zip
Avoid zero-sized leaf allocations in `BTreeMap`
When both the key and value types were zero-sized, `BTreeMap` previously
called `heap::allocate` with `size == 0` for leaf nodes, which is
undefined behavior, and jemalloc would attempt to read invalid memory,
crashing the process.

This avoids undefined behavior by allocating enough space to store one
edge in leaf nodes that would otherwise have `size == 0`. Although this
uses extra memory, maps with zero-sized key types that have sensible
implementations of the ordering traits can only contain a single
key-value pair (and therefore only a single leaf node), and maps with
key and value types that are both zero-sized have few uses, if any.

Furthermore, this is a temporary fix that will likely be unnecessary
once the `BTreeMap` implementation is rewritten to use parent pointers.

Closes #28493.
Diffstat (limited to 'src/libsyntax/errors')
0 files changed, 0 insertions, 0 deletions