Skip to content

Demangler: handle errors in demangleType #74767

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

Merged
merged 2 commits into from
Jul 8, 2024

Conversation

eeckstein
Copy link
Contributor

Makes sure that invalid runtime type strings result in errors and not fail silently.
In worst case this could lead to wrong reconstructed metatypes which can result in all kind of memory corruption.

Also add an option -type to the swift-demangle tool to test demangleType

relates to rdar://129861211

@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein requested a review from rjmccall June 27, 2024 09:55
@eeckstein eeckstein force-pushed the demangle-type-error-handling branch 2 times, most recently from ee43266 to 5a0faf4 Compare July 1, 2024 17:29
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein force-pushed the demangle-type-error-handling branch from 5a0faf4 to 50d2531 Compare July 2, 2024 11:05
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein
Copy link
Contributor Author

@swift-ci test macos


return createNode(Node::Kind::Suffix, Text);
return Result;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there harm to keeping the Suffix production? The runtime demangler should never accept it as a valid mangling, but it's helpful when demangling generated symbol names in binaries. Could it be kept as an option?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it can also be helpful when debugging mangling errors, since it generally points at exactly what you messed up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change only affects demangleType (the runtime demangler). Nothing changes for demangling symbols

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debugging mangling errors

Pro tip: Demangler::dump() prints the internal state of the demangler which is very useful for debugging mangling problems

eeckstein added 2 commits July 5, 2024 11:37
Makes sure that invalid runtime type strings result in errors and not fail silently.
In worst case this could lead to wrong reconstructed metatypes which can result in all kind of memory corruption.

relates to rdar://129861211
The motivation for this is to test the `Demangler::demangleType` API.
@eeckstein eeckstein force-pushed the demangle-type-error-handling branch from 50d2531 to b9cb593 Compare July 5, 2024 09:47
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein merged commit 47baa9f into swiftlang:main Jul 8, 2024
5 checks passed
@eeckstein eeckstein deleted the demangle-type-error-handling branch July 8, 2024 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants