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
We're investigating using CXX to create multiple DLLs for incorporation into a large C++ project.
Non-inline functions with multiple definitions living in separate DLLs are okay when they aren't exposed directly or indirectly (e.g. via. exceptions) over the DLLs' public interfaces. Consequently, cbindgen, in exposing only functions particular to the crate, effectively insulates Rust runtimes within the DLLs.
CXX when used in multiple DLLs, on the other hand, will expose non-inline functions with multiple definitions, such as rust::String's destructor. This is fine as long as these functions's implementations do not access an object with multiple definitions (namely, global state in the DLL's data section). The implementation of rust::String::~Stringcalls ManuallyDrop::drop which then calls drop_in_place. Do we have any guarantees that drop_in_place will not access global state?
If the answer is "no" it seems like linking a single executable to multiple DLLs that use CXX results in undefined behavior.
The text was updated successfully, but these errors were encountered:
We're investigating using CXX to create multiple DLLs for incorporation into a large C++ project.
Non-inline functions with multiple definitions living in separate DLLs are okay when they aren't exposed directly or indirectly (e.g. via. exceptions) over the DLLs' public interfaces. Consequently, cbindgen, in exposing only functions particular to the crate, effectively insulates Rust runtimes within the DLLs.
CXX when used in multiple DLLs, on the other hand, will expose non-inline functions with multiple definitions, such as rust::String's destructor. This is fine as long as these functions's implementations do not access an object with multiple definitions (namely, global state in the DLL's data section). The implementation of
rust::String::~String
callsManuallyDrop::drop
which then callsdrop_in_place
. Do we have any guarantees thatdrop_in_place
will not access global state?If the answer is "no" it seems like linking a single executable to multiple DLLs that use CXX results in undefined behavior.
The text was updated successfully, but these errors were encountered: