Skip to content

[Runtime] Ensure we *always* generate names for ObjC classes. #65140

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 1 commit into from
Apr 27, 2023

Conversation

al45tair
Copy link
Contributor

If something fails while trying to generate a name for an ObjC class, we fall back to a generated name based on the metadata pointer. This ensures that we won't crash, and if the name turns up in the debugger or somewhere it should be obvious that something went wrong.

rdar://107718586

@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test

@al45tair al45tair requested a review from mikeash April 13, 2023 14:13
// Prefix plus 16 hex digits plus NUL
size_t allocationSize = strlen(EMERGENCY_PREFIX) + 16 + 1;
auto nameBuf = (char *)swift_slowAlloc(allocationSize, 0);
snprintf(nameBuf, allocationSize,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we count on asprintf to be available whenever ObjC interop is enabled? That would make this a bit less scary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We probably could at that. I always forget about asprintf(). I'll update the PR to use that.

If something fails while trying to generate a name for an ObjC class,
we fall back to a generated name based on the metadata pointer.  This
ensures that we won't crash, and if the name turns up in the debugger
or somewhere it should be obvious that something went wrong.

rdar://107718586
@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test

@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test

@al45tair al45tair merged commit 2e36235 into swiftlang:main Apr 27, 2023
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.

2 participants