about summary refs log tree commit diff
path: root/compiler/rustc_driver_impl/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-05-25 22:15:17 +0200
committerGitHub <noreply@github.com>2024-05-25 22:15:17 +0200
commit7fb81229d3deec73ae400e6ad755a64f9125f1e4 (patch)
tree241bb89dc6ea4967a9629ec2161bc494b33b25d4 /compiler/rustc_driver_impl/src
parent2a1b63251a680e784b904df3354dc80f2441ea56 (diff)
parent5cb53bc34d462a59629e5430cf2e29fe6820c550 (diff)
downloadrust-7fb81229d3deec73ae400e6ad755a64f9125f1e4.tar.gz
rust-7fb81229d3deec73ae400e6ad755a64f9125f1e4.zip
Rollup merge of #123803 - Sp00ph:shrink_to_fix, r=Mark-Simulacrum
Fix `VecDeque::shrink_to` UB when `handle_alloc_error` unwinds.

Fixes #123369

For `VecDeque` it's relatively simple to restore the buffer into a consistent state so this PR does just that.

Note that with its current implementation, `shrink_to` may change the internal arrangement of elements in the buffer, so e.g. `[D, <uninit>, A, B, C]` will become `[<uninit>, A, B, C, D]` and `[<uninit>, <uninit>, A, B, C]` may become `[B, C, <uninit>, <uninit>, A]` if `shrink_to` unwinds. This shouldn't be an issue though as we don't make any guarantees about the stability of the internal buffer arrangement (and this case is impossible to hit on stable anyways).

This PR also includes a test with code adapted from #123369 which fails without the new `shrink_to` code. Does this suffice or do we maybe need more exhaustive tests like in #108475?

cc `@Amanieu`

`@rustbot` label +T-libs
Diffstat (limited to 'compiler/rustc_driver_impl/src')
0 files changed, 0 insertions, 0 deletions