wishawa
February 21, 2022, 10:08pm
#1
I'm currently playing with with "Unmovable" type taken from this github issue comment (credit @Kimundi ). I've ported it to work with modern Rust versions: playground link .
I am trying to think of ways to leak it. So far I've found only one: locking the type in an async block and leaking that block (playground link ).
Does anyone know of any other way to leak this Unmovable type?
H2CO3
February 21, 2022, 10:39pm
#2
Well, trivially, you could leak it before it is locked using Box::leak()
.
wishawa
February 21, 2022, 10:58pm
#4
Nice! I'm surprised it never crossed my mind to leak it before locking
wishawa
February 21, 2022, 11:05pm
#5
oh wow. no heap needed at all. nice!
Yandros
February 21, 2022, 11:24pm
#6
FWIW, this ManuallyDrop
escape hatch is precisely what prevented this "idiom" into leading to a function-backed implementation of stack pinning (so close though).
1 Like
Also, you can just exit without running destuctors. Or have your thread killed, perhaps implicitly. The latter is probably something like what is happening with your async
block.
2 Likes