Commit Graph

45 Commits

Author SHA1 Message Date
xgopilot
eb0fa2e107 fix(ssa): revert unnecessary formatting changes
Reverted two unnecessary formatting changes based on code review:
- ssa/interface.go: Restored single-line format for val function
- ssa/abitype.go: Moved pkg variable declaration back to original position

These changes don't affect functionality, just code formatting.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-30 08:06:40 +00:00
xgopilot
79bf753c0e fix(ssa): use empty PkgPath for anonymous interfaces
Based on meeting discussion, this commit reverts the previous approach
of extracting PkgPath from interface methods. Instead, anonymous
interfaces now use an empty PkgPath string, and the runtime's methods()
function handles empty PkgPath by returning all methods.

Changes:
- Reverted unsafeInterface() to remove originType parameter
- Set anonymous interface PkgPath to empty string in abitype.go:202
- Added early return in methods() in z_face.go for empty PkgPath
- All call sites of unsafeInterface() updated to pass rawIntf directly

This approach is cleaner because anonymous interfaces don't belong to
any package, and the compiler already guarantees safety for cross-package
private method access.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-30 07:33:20 +00:00
xgopilot
88d32c9930 fix(ssa): correct PkgPath for interface metadata in cross-package conversions
Fixes #1370 - Segmentation Fault When Calling Interface Private Methods Cross-Package

This commit fixes a critical bug where interface metadata's PkgPath was incorrectly
set when converting concrete type pointers to interfaces with private methods across
package boundaries.

Problem:
- When a concrete type pointer was converted to an interface with private methods
  in a package different from the interface definition package, the compiler
  incorrectly set the interface metadata's PkgPath to the current compilation
  package instead of the interface definition package
- This caused the runtime to only fill exported methods in the itab, leaving
  private method slots as NULL (0x0), resulting in segmentation faults

Solution:
- Modified abiInterfaceOf() in ssa/abitype.go to extract the package path from
  the interface's private methods (if any)
- Use that package path instead of the current compilation package path
- Fall back to current package path only if all methods are exported

Changes:
- ssa/abitype.go: Use abi.PathOf() to get correct package path
- ssa/interface.go: Refactor to simplify interface type handling
- Added comprehensive test cases and demos for go/types, go/token, and go/ast
- Updated all test outputs to reflect correct interface metadata generation

This fix resolves segmentation faults when using Go standard library interfaces
and user-defined interfaces with private methods across package boundaries.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-30 06:24:23 +00:00
visualfc
5592a8fc26 ssa: fix abiTupleOf 2025-09-25 20:16:44 +08:00
Li Jie
ed366568b4 move out c/cpp/py 2025-04-03 16:26:11 +08:00
Li Jie
1172e5bdce build: separate compiler and libs 2025-01-08 14:59:01 +08:00
visualfc
ef28abe896 internal/runtime: funcStr, interfaceStr, array str 2024-12-20 12:33:34 +08:00
visualfc
d251232f8a internal/runtime: named(ptr) type preset for method type 2024-12-20 11:37:30 +08:00
visualfc
e55a5d7486 internal/runtime: NewNamedInterface, InitNamedInterface 2024-12-16 12:07:13 +08:00
visualfc
8fb0dfad94 ssa: abiNamed use NameOf 2024-11-26 12:46:11 +08:00
visualfc
d62c2d913e ssa: abi check interface method 2024-10-12 15:59:10 +08:00
visualfc
9eb9b48534 internal/lib/reflect: type.Field FieldByIndex FieldByName 2024-09-22 20:56:15 +08:00
visualfc
2feb3e1d7a ssa: prog.linkname; abi llvm.LinkOnceAnyLinkage always 2024-08-20 21:11:27 +08:00
visualfc
3435b6c4a4 cl: makeInterface check instance named 2024-08-13 21:59:19 +08:00
visualfc
05a01cd803 ssa: fix abi map init 2024-08-06 22:24:21 +08:00
Aofei Sheng
482f796bad ssa: add llgo:link support to Builder.abiMthd 2024-08-04 11:00:31 +08:00
visualfc
024b30d0b7 ssa: fix abiNamed for llc verified 2024-07-22 12:38:07 +08:00
visualfc
cf75e3e664 ssa: abiNamed set underlying size 2024-07-17 10:42:04 +08:00
visualfc
73b42f924d ssa: fix setDirectIface 2024-07-08 20:19:25 +08:00
visualfc
91ba215568 internal/runtime: check abi.KindDirectIface 2024-07-04 18:59:41 +08:00
visualfc
bcb217c1da ssa: set pointer directiface 2024-07-04 18:50:37 +08:00
visualfc
490a16a8df ssa: index check take address 2024-07-04 18:50:36 +08:00
visualfc
28d8c56534 ssa: index take addr 2024-07-04 18:50:36 +08:00
visualfc
439e377111 ssa: map delete, map eql nil 2024-07-04 18:50:36 +08:00
visualfc
2ccd1625e7 ssa: support runtime.map 2024-07-04 18:50:36 +08:00
visualfc
2153cf39b5 ssa: chan send/recv 2024-07-02 20:52:25 +08:00
visualfc
8772c85964 ssa: fix abi patch types.pointer 2024-07-02 08:40:44 +08:00
xushiwei
8c45eb7524 abitype: support Patch 2024-06-30 11:53:12 +08:00
visualfc
7443d41444 runtime: global abi basic 2024-06-25 14:41:32 +08:00
visualfc
ef3619350d ssa: fix abiType & abiNamedOf 2024-06-25 12:17:03 +08:00
visualfc
16352df5b1 ssa: fix abiType && abiMethoOf 2024-06-25 10:22:32 +08:00
visualfc
c090c34491 runtime: panic any custometype 2024-06-23 21:51:00 +08:00
visualfc
9ae7d4f2bf ssa: abiTypeInit kind 2024-06-20 22:09:26 +08:00
Li Jie
e7fcb068d9 ssa: fix reentrant of ABI initialization 2024-06-20 20:07:59 +08:00
visualfc
ec1cca7ca4 ssa: global use elem type 2024-06-14 10:09:46 +08:00
visualfc
0c321c8c98 ssa: binop equal(func,slice,array,struct) and buildConstStr 2024-06-14 10:04:01 +08:00
xushiwei
45f470e3a7 merge upstream 2024-06-12 21:02:26 +08:00
xushiwei
b787de0163 runtime: rethrow/panic; llgo/ssa: DeferData; Null => Nil 2024-06-12 17:26:07 +08:00
visualfc
f33796797d cl: _testgo/reader 2024-06-11 12:15:18 +08:00
visualfc
bdf1c275c4 ssa: interface equal 2024-06-11 10:24:30 +08:00
visualfc
2fce2318ed ssa: set method.name to pkg.name if private 2024-06-06 07:30:59 +08:00
xushiwei
410f9dd759 llgo/ssa: EndBuild 2024-06-02 21:54:51 +08:00
xushiwei
76c1800a53 abiTypes: abiTypeInit fix 2024-05-31 08:12:27 +08:00
xushiwei
3b2f01e974 abiTypes 2024-05-31 07:35:22 +08:00
xushiwei
e5f38a6fc1 abitype.go 2024-05-28 23:58:37 +08:00