fix: generate valid function pointers for embedded type's unexported methods#1598
fix: generate valid function pointers for embedded type's unexported methods#1598luoliwoshang wants to merge 2 commits intogoplus:mainfrom
Conversation
Summary of ChangesHello @luoliwoshang, 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 primarily addresses a critical runtime panic related to how interface method tables are generated for types that embed other types with unexported methods. The fix ensures that the compiler correctly generates function pointers for these methods, preventing crashes. Additionally, it introduces a new command-line flag to enhance visibility into the build process by printing executed commands and significantly improves the robustness of 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. Ignored Files
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 runtime panic that occurred when using interfaces with unexported methods on embedded types from different packages. The core change in ssa/abitype.go properly generates valid function pointers in the interface method table for these methods. In addition to the bug fix, this PR introduces substantial improvements to the build system, including better command tracing via a new -x flag, and significantly enhances support for panic/defer on baremetal targets by implementing a setjmp/longjmp-based mechanism. The changes are well-structured, and the new test cases effectively validate the fix. I have one minor suggestion to improve the maintainability of a test script.
4f82652 to
c17e1b3
Compare
Code Review SummaryOverall Assessment: Approved ✓ This PR correctly fixes the nil function pointer issue for unexported methods inherited from embedded types. The fix is minimal, focused, and includes a proper regression test. Strengths:
Minor Suggestions:
The generated |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1598 +/- ##
==========================================
- Coverage 91.05% 91.05% -0.01%
==========================================
Files 45 45
Lines 11933 11922 -11
==========================================
- Hits 10866 10855 -11
Misses 892 892
Partials 175 175 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
dc23a5d to
f2717a8
Compare
…hods This merges the fix for generating valid function pointers for embedded type's unexported methods. - Fix ssa/abitype.go: remove skipfn logic that was setting Ifn_ to nil - Add regression tests for embedunexport-1598 - Update out.ll test files Original PR: goplus#1598 Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
|
@xgopilot resolve conflict |
Merge Conflict ResolvedMerge conflicts have been successfully resolved. Changes made:
PR created in fork: luoliwoshang#195 @luoliwoshang Please merge this PR into your |
…methods (goplus#1597) Previously, when a type embedded another type from a different package, the unexported methods inherited from the embedded type would have nil function pointers (Ifn_) in the method table. This caused runtime panics when interfaces with unexported methods (like types.Object) were used. The fix removes the skipfn logic that was setting Ifn_ to nil for methods from other packages. Now all methods, including unexported ones from embedded types, get valid function pointers generated. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
f2717a8 to
f315ea4
Compare
Summary
Fix runtime panic when using interfaces with unexported methods on types that embed other types from different packages.
Problem
When a type embeds another type from a different package to implement an interface that has unexported methods, the interface method table (itab) contained nil function pointers for those unexported methods. This caused a runtime panic when the interface method was called.
For example:
Root Cause
In
ssa/abitype.go, when generating the method table for a type, unexported methods from other packages had theirIfn_(interface function pointer) set to nil:Fix
Remove the
skipfnlogic. Now all methods, including unexported ones from embedded types, get valid function pointers generated.Test Plan
out.llfiles for affected test cases🤖 Generated with Claude Code