Closed
Description
So during the all-hands we identified a use-case that would be good to be documented in the unsafe code guidelines.
There are at least three sources of "cancellation" which might end up "removing" (in Taylor’s words) a value without "dropping" it, which in turn results in unsoundness for e.g. rayon, crossbeam, &pin stuff. These sources are:
longjmp
/setjmp
(used in practice for error handling by rust lua and perhaps many other embedded languages/interpreters);pthread_cancel
: which can run either an asynchronous unwinding exception (might occur at any program point) or raise an unwindingexception at well specified points such assleep
; exact behaviour is specified bypthread_setcancelstate
.pthread_exit
,pthread_kill
: which will "stop" the thread, potentially executing some arbitrary code and cleaning the thread up (freeing thread’s stack).
There’s no question that these functions may be useful in one scenario or the other, so it would be good if we figured out scenarios in which these functions are sound to use (e.g. if the thread stack contains only Copy
types) and encoded this information into our unsafe code guidelines book.