-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Reflection] Prevent symbolic reference mangling induced crashes #37514
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
[Reflection] Prevent symbolic reference mangling induced crashes #37514
Conversation
Do we understand what that means, i.e., when we hit the mitigation, do we create incomplete mangled names that might cause crashes later? |
@jckarter any ideas on how to handle symbolic references here? |
Good question, and no. I am working on being able to reproduce the bug reports, but without that we don't know what the downstream effects are. |
You want to call the I am very confused by all this, though. Does |
@mikeash I have updated this PR to handle the one potential case we discussed, where The fix is to thread through |
@swift-ci test |
d9bc399
to
265c15a
Compare
@swift-ci nominate |
@swift-ci test |
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.
Looks good. Thank you!
Closing for this branch only. See linked PRs for |
@swift-ci test |
Based on lldb crash logs,
TypeRefBuilder
is crashing on instances of symbolic references in mangled names.The crash happens when a symbolic reference is attempted to be mangled (via
mangleNode()
), which leads to a call tounreachable
which aborts. For library usage, such as from lldb, these cases need to be handled without an abort.The improvements to gracefully handle symbolic references are:
normalizeReflectionName
fromstd::string
tollvm::Optional<std::string>
useOpaqueTypeSymbolicReferences
Both of these start in
normalizeReflectionName
.First, the call to
demangleTypeRef()
now setsuseOpaqueTypeSymbolicReferences
to false. Without this,demangleTypeRef()
can return a node of kindOpaqueTypeDescriptorSymbolicReference
, which is guaranteed to fail in this code path when in subsequent call tomangleNode()
.Second, if the result of
demangleTypeRef()
is one of the symbolic reference kinds, then the function exits early with a value ofNone
. Callers ofnormalizeReflectionName()
are now forced to handle such cases, where the mangled name could not be normalized.In
TypeRefBuilder::getFieldTypeInfo()
, ifnormalizeReflectionName()
fails, then the corresponding field is not supported, or in other words, dropped.rdar://77613304