actix-web: Should we drop failure?

actix wont support Send, failure enforce everyone to use Send + Sync

should we just use our own Fail trait

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (15 by maintainers)

Most upvoted comments

FWIW my interest in this topic is twofold. I’m a strong proponent of retaining the Sync and Send traits in failure and have the ecosystem standardize on failure but have a convenient story for people that cannot fulfill this bounds. So I want to see this particular issue also in the context of failure itself.

Note that moving a !Send value to another thread is almost always UB, even if trying to guard with the ThreadId. The problem is the destructor: even if you never access any of it’s memory in the other thread, when it is dropped, the destructor can mutate the memory without synchronization.

That could happen when the “guard” drops naturally, or if the thread closes naturally (or because of a panic).

Perhaps in Drop of such a guard, you could force the value to leak if not on the same thread, which is better than UB, but it’s probably better to just not be Send.