sync: align Cond with stdlib to fix interface nil comparisons#1494
sync: align Cond with stdlib to fix interface nil comparisons#1494xushiwei merged 1 commit intogoplus:mainfrom
Conversation
Summary of ChangesHello @cpunion, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug in the SSA generation process that led to the creation of malformed LLVM IR when comparing an interface value with a non-interface value. The core change ensures that such comparisons are correctly handled by explicitly converting the non-interface operand to an interface, thereby aligning the generated IR with Go's runtime semantics for interface equality and preventing runtime errors or unexpected behavior. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly fixes a bug that caused invalid LLVM IR generation for comparisons between interface and non-interface types. The approach of converting the non-interface operand to an interface before comparison is sound. The added test case effectively covers the failing scenario. I have a couple of suggestions to improve code readability and maintainability in both the fix and the new test file.
Code Review SummaryGreat work on fixing the invalid LLVM IR generation for mixed interface/pointer comparisons! The approach is sound, but there's a critical bug that needs to be fixed. Critical Issue:
Important Improvements:
Security & Performance: No concerns. The code is type-safe and the interface conversion overhead is acceptable for correctness. Please address the critical bug before merging. |
1277a3f to
53192ce
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1494 +/- ##
=======================================
Coverage 90.58% 90.58%
=======================================
Files 43 43
Lines 11429 11429
=======================================
Hits 10353 10353
Misses 914 914
Partials 162 162 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
8420770 to
08f97ad
Compare
ff34dab to
26e43bb
Compare
Fixes #1493
Root cause: llgo’s sync.Cond diverged from the stdlib layout. It stored a *sync.Mutex and didn’t expose Cond.L, so code that accessed Cond.L (an interface) loaded a pointer instead. Comparisons like p.c.L == nil or nil == p.c.L then produced invalid LLVM IR (icmp between pointer and interface).
Changes: