-
-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Differentiate C++ catch clauses from D ones with __cpp_type_info_ptr #2590
Conversation
Looking good, thanks a lot, I remember having trouble to understand what DMD was doing there.
Only possible if the commit is in the LDC repo, i.e., already in the main We'll also have to add your testcase to dmd-testsuite, too bad this quite important aspect of DMD's implementation isn't tested at all. Edit: Like here, throwing C++ function already available. |
2aae2b9
to
893890d
Compare
Added a |
OutBuffer mangleBuf; | ||
mangleBuf.writestring("_D"); | ||
mangleToBuffer(p.cd, &mangleBuf); | ||
mangleBuf.printf("%d%s", 18, "_cpp_type_info_ptr"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have the concept of 'IR mangles', to give the TargetABI a chance to tweak the mangled name (e.g., to prevent LLVM from implicitly prepending an underscore). So please use getIRMangledVarName(mangleBuf.peekString(), LINKd)
as name for the getOrCreateGlobal()
call below. While at it, please also include the dmd-testsuite update, I'll merge then.
893890d
to
7693a49
Compare
…o pointers inside __cpp_type_info_ptr class instances like DMD does. Previously assuming in the personality routine that encountering a C++ exception meant that catch clauses were raw std::type_info pointers was wrong in cases like: try { throwStdException(); // external C++ function throwing a std::exception } catch (Throwable t) { (...) } Generated __cpp_type_info_ptr constants receive the same mangling that they do within DMD.
Ready for m-.. oh you already did, thanks! |
…o pointers inside __cpp_type_info_ptr class instances like DMD does. (ldc-developers#2590) Previously assuming in the personality routine that encountering a C++ exception meant that catch clauses were raw std::type_info pointers was wrong in cases like: try { throwStdException(); // external C++ function throwing a std::exception } catch (Throwable t) { (...) } Generated __cpp_type_info_ptr constants receive the same mangling that they do within DMD. (cherry picked from commit bf8cd78)
The following code currently segfaults:
Because the personality routine in
druntime/rt/dwarfeh.d
makes the wrong assumption that when it encounters a C++ exception, the catch clauses in the action table that it gets to examine are rawstd::type_info
pointers, which isn't the case if it's aThrowable
(or derived) catch.To make it possible for the personality routine to differentiate the two kinds of catch clauses, DMD wraps
std::type_info
pointers inside__cpp_type_info_ptr
class instances, and this is what this PR implements for LDC.Associated ldc/druntime PR: ldc-developers/druntime#119
BTW should the druntime submodule be updated in the ldc commit too?