- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The C++ runtime from the Windows SDK seems to have a problem with multiple inheritance.
Here is a minimal reproduction :
struct Base1 {
int N1{};
virtual ~Base1() = default;
};
struct Base2 {
int N2{};
virtual ~Base2() = default;
};
struct Derived : public Base1, public Base2 {
int D{};
virtual ~Derived() = default;
};
void test()
{
Base1* foo1 = new Derived;
Base1* bar1 = dynamic_cast<Base1*>(foo1);
Base2* baz1 = dynamic_cast<Base2*>(foo1);
Base2* foo2 = new Derived;
Base2* baz2 = dynamic_cast<Base2*>(foo2);
Base1* bar2 = dynamic_cast<Base1*>(foo2); // => only this one crashes, only on windows with the sgx runtime
}
The call-stack at the crash is :
enclave.signed.dll!abort() Line 1054 (c:\SGXWindows\src_Release\windows-trunk\sdk\trts\win\trts_pic.asm:1054)
enclave.signed.dll!__assert(const char * file, int line, const char * func, const char * failedexpr) Line 50 (c:\SGXWindows\src_Release\windows-trunk\sdk\tlibc\gen\assert.c:50)
enclave.signed.dll!get_cross_cast_result(const _rtti_base_descriptor * ptarget_type_bcd, const _rtti_base_descriptor * psrc_type_bcd) Line 71 (c:\SGXWindows\src_Release\windows-trunk\sdk\cpprt\win\rtti\rtti.cpp:71)
enclave.signed.dll!get_multiple_inheritance_bcd(const void * pcomplete_object, const _rtti_complete_object_locator * pcomplete_object_locator, const _rtti_type_descriptor * psrc_type_id, __int64 inptr_delta, const _rtti_type_descriptor * ptarget_type_id) Line 201 (c:\SGXWindows\src_Release\windows-trunk\sdk\cpprt\win\rtti\rtti.cpp:201)
enclave.signed.dll!__RTDynamicCast(void * inptr, long vf_delta, void * src_type, void * target_type, int is_reference) Line 390 (c:\SGXWindows\src_Release\windows-trunk\sdk\cpprt\win\rtti\rtti.cpp:390)
Note that this works on Linux, and when the inheritance is virtual.
By the way, is there a reason why the SDK is open-source on Linux and not on Windows ? My guess is that with the actual sources mentioned in the call-stack, a fix and a pull-request might have been possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jean-Jacques,
This was a bug that has been fixed and will be part of the next release.
Sincerely,
Sahira
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am looking into this and will get back to you shortly.
Sincerely,
Sahira
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jean-Jacques,
Thanks for your patience, I've escalated this issue to engineering to look at. I will let you know when I have more information.
Sincerely,
Sahira
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jean-Jacques,
This was a bug that has been fixed and will be part of the next release.
Sincerely,
Sahira

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page