You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
create_extern_c_wrapper currently defines a safe function via a C-compatible ABI and uses unsafe blocks to transform raw pointers into slices. An unsafe block is basically an assertion to the compiler, that the author is able to check the relevant preconditions for the unsafe operations to be correct. However, a raw pointer can never be verified without additional information, e.g. even if it is non-null and the alignment is valid, it could still be dangling to pointing into a completely different allocation.
This suggests that it is the responsibility of the calling (C++) code to ensure that the pointers are valid as the Rust code has no ability to check the pointers and hence justify the unsafe blocks. This would be expressed by marking the whole function unsafe which is fitting as the calling C++ is considered "unsafe" by definition.
The text was updated successfully, but these errors were encountered:
create_extern_c_wrapper
currently defines a safe function via a C-compatible ABI and usesunsafe
blocks to transform raw pointers into slices. Anunsafe
block is basically an assertion to the compiler, that the author is able to check the relevant preconditions for the unsafe operations to be correct. However, a raw pointer can never be verified without additional information, e.g. even if it is non-null and the alignment is valid, it could still be dangling to pointing into a completely different allocation.This suggests that it is the responsibility of the calling (C++) code to ensure that the pointers are valid as the Rust code has no ability to check the pointers and hence justify the
unsafe
blocks. This would be expressed by marking the whole function unsafe which is fitting as the calling C++ is considered "unsafe" by definition.The text was updated successfully, but these errors were encountered: