Skip to content

Initial work on closing GC holes in bindings #22345

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 17 commits into from
Mar 17, 2025

Conversation

rolfbjarne
Copy link
Member

  • Generate GC.KeepAlive where necessary in bgen
  • Add analyzer to flag missing GC.KeepAlive calls
  • Update manual bindings to fix errors from the analyzer

Contributes to #10146

Original PR #22337 from @filipnavara.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Member

@dalexsoto dalexsoto left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your contribution as always, is there any chance you can provide some tests for this?

@filipnavara
Copy link
Member

Thanks a lot for your contribution as always, is there any chance you can provide some tests for this?

I will submit a test for the analyzer soon (along with few more fixes). There's not much else that can be tested easily. I run a part of the tests under CoreCLR with DOTNET_GCStress=2 but that's more of a smoke test than systematic testing.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@filipnavara
Copy link
Member

I'll fix the analyzer tests tomorrow. I made the dumb mistake of using Class in the test cases (chosen at random) and then making an exclusion specifically for it...

…hrowOnNull (#22395)

Replace usages of Runtime.ThrowOnNull with GetNonNullHandle extension
method
Update analyzer tests
@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #e325b09] Build passed (Build packages) ✅

Pipeline on Agent
Hash: e325b094b881cc37a4d07d33142c12863a0ff63f [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [PR Build #e325b09] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: e325b094b881cc37a4d07d33142c12863a0ff63f [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ [CI Build #e325b09] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: e325b094b881cc37a4d07d33142c12863a0ff63f [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #e325b09] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: e325b094b881cc37a4d07d33142c12863a0ff63f [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #e325b09] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: e325b094b881cc37a4d07d33142c12863a0ff63f [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #e325b09] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: e325b094b881cc37a4d07d33142c12863a0ff63f [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

✅ API diff for current PR / commit

.NET ( No breaking changes )

❗ API diff vs stable (Breaking changes)

.NET ( ❗ Breaking changes ❗ )

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) Unable to create gist: Response status code does not indicate success: 422 (Unprocessable Entity). (raw diff) - Please review changes)

Pipeline on Agent
Hash: e325b094b881cc37a4d07d33142c12863a0ff63f [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #e325b09] Windows Integration Tests passed 💻

All Windows Integration Tests passed.

Pipeline on Agent
Hash: e325b094b881cc37a4d07d33142c12863a0ff63f [PR build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

🚀 [CI Build #e325b09] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 115 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 8 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 8 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: e325b094b881cc37a4d07d33142c12863a0ff63f [PR build]

@@ -1713,7 +1713,7 @@ void GenerateTrampolinesForQueue (TrampolineInfo [] queue)
string cast_a = "", cast_b = "";
Copy link
Member Author

Choose a reason for hiding this comment

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

This code doesn't look right from a first glance, so why wouldn't it be flagged by the analyzer?

returnformat = "return NSArray.FromNSObjects({0}).Handle;";

Copy link
Member

@filipnavara filipnavara Mar 17, 2025

Choose a reason for hiding this comment

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

I'm afraid the analyzer is not run on the bgen generated code, only on the manual bindings. We should probably look into doing that. Perhaps @mandel-macaque has an idea where should that be wired?

Copy link
Member

Choose a reason for hiding this comment

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

Let's add it in a diff PR, we can merge it with this and then see what complains. It looks like we would need to fix both bgen and the new rgen implementation.

Copy link
Member

@filipnavara filipnavara Mar 17, 2025

Choose a reason for hiding this comment

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

I agree we should tackle that in a follow up PR. The PR is big as it is and fixing the manual bindings is likely the harder part.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copy link
Member Author

@rolfbjarne rolfbjarne left a comment

Choose a reason for hiding this comment

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

All looks good to me, we can analyze the code from bgen in a separate PR.

Copy link
Member

@dalexsoto dalexsoto left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@vs-mobiletools-engineering-service2
Copy link
Collaborator

💻 [CI Build #e325b09] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: e325b094b881cc37a4d07d33142c12863a0ff63f [PR build]

Copy link
Member

@mandel-macaque mandel-macaque left a comment

Choose a reason for hiding this comment

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

Lets land it and then update our build to include analyzer for the generated code and fix any issues in bgen/rgen.

@rolfbjarne rolfbjarne merged commit 8d78327 into main Mar 17, 2025
47 checks passed
@rolfbjarne rolfbjarne deleted the dev/filipnavara/handle-gchole branch March 17, 2025 16:33
@rolfbjarne
Copy link
Member Author

@filipnavara thanks a lot for your great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution ❤
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants