-
Notifications
You must be signed in to change notification settings - Fork 545
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
Conversation
- Add analyzer to flag missing GC.KeepAlive calls - Update manual bindings to fix errors from the analyzer
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
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 |
Improve NativeObjectHandleAnalyzer detection of INativeObject, handle generic parameters
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I'll fix the analyzer tests tomorrow. I made the dumb mistake of using |
…hrowOnNull (#22395) Replace usages of Runtime.ThrowOnNull with GetNonNullHandle extension method Update analyzer tests
✅ [CI Build #e325b09] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #e325b09] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ [CI Build #e325b09] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #e325b09] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #e325b09] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #e325b09] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
✅ API diff for current PR / commit.NET ( No breaking changes )❗ API diff vs stable (Breaking changes).NET ( ❗ Breaking changes ❗ )ℹ️ Generator diffGenerator 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 |
This comment has been minimized.
This comment has been minimized.
💻 [CI Build #e325b09] Windows Integration Tests passed 💻✅ All Windows Integration Tests passed. Pipeline on Agent |
🚀 [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 Pipeline on Agent |
src/rgen/Microsoft.Macios.Bindings.Analyzer/NativeObjectHandleAnalyzer.cs
Show resolved
Hide resolved
@@ -1713,7 +1713,7 @@ void GenerateTrampolinesForQueue (TrampolineInfo [] queue) | |||
string cast_a = "", cast_b = ""; |
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.
This code doesn't look right from a first glance, so why wouldn't it be flagged by the analyzer?
Line 590 in ad60117
returnformat = "return NSArray.FromNSObjects({0}).Handle;"; |
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.
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?
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.
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.
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.
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.
This comment has been minimized.
This comment has been minimized.
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.
All looks good to me, we can analyze the code from bgen in a separate PR.
✅
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.
LGTM 👍
💻 [CI Build #e325b09] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
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.
Lets land it and then update our build to include analyzer for the generated code and fix any issues in bgen/rgen.
@filipnavara thanks a lot for your great work! |
Contributes to #10146
Original PR #22337 from @filipnavara.