Skip to content
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

[Swift runtime features] Validate metadata pointers before saving them into cache #2966

Open
Tracked by #2846
jkurdek opened this issue Jan 29, 2025 · 0 comments
Open
Tracked by #2846
Assignees
Labels
area-SwiftBindings Swift bindings for .NET

Comments

@jkurdek
Copy link
Member

jkurdek commented Jan 29, 2025

#2867 added caching for type metadata. Type metadata pointers will come from two sources, ISwiftObject.GetTypeMetadata() and internal storage (for primitives). It might happen that ISwiftObject.GetTypeMetadata() returns a IntPtr.Zero (e.g. current implementation of AnyType). This is not a valid TypeMetadata and we should fail and produce a meaningful error on receiving it. Otherwise the program might fail without any meaningful message on pinvoke call.

In #2958 I added safeguards around static accessors to fail when TypeMetadata is invalid, however caching happens before the check. On following reads of the feral TypeMetadata the incorrect value is returned silently.

We should refactor the caching mechanism to ensure that only valid values are cached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-SwiftBindings Swift bindings for .NET
Projects
None yet
Development

No branches or pull requests

1 participant