fmt::Arguments
is Send+Sync
regardless of its captured arguments
#45197
Labels
C-bug
Category: This is a bug.
I-unsound
Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
P-high
High priority
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
fmt::Arguments<'a>
is only parameterized on lifetime. The types of the captured arguments are erased in the contained[ArgumentV1<'a>]
. Nothing restricts theArguments
aggregate from beingSend
orSync
, so by OIBIT it's both. Thus this compiles:I'm not sure if there are any realistic ways to accidentally abuse this, but here's a deliberate example. The spawned thread will read the
Cell
through the arguments, even while the main thread modifies it.playground
The text was updated successfully, but these errors were encountered: