Open
Description
During a soundness audit for the unsafe code in dispatch2
, we noticed a potential soundness issue where dyn Fn() -> u8
was being transmuted to dyn Fn() -> bool
here. This is unsound because of the potential for vtable layout differences between the two types of functions, so even though the bits are copied when transmuting, the memory layout could be unexpected and therefore lead to corruption (ABI incompatibility between u8 and bool). Additionally, if calling convention somehow differs between the two types of functions, this could also lead to issues with memory corruption.