Commit Graph

46 Commits

Author SHA1 Message Date
xgopilot
b62dafbc3a fix(ssa): use abi.PathOf() for correct package path in interface metadata
Fixes os.ReadDir segfault caused by package path mismatch between llgo
overlay packages and canonical standard library paths.

The issue occurred in: os.ReadDir → sort.Slice → reflectlite.Swapper
where internal/reflectlite.Type interface has private methods common()
and uncommon(). Using mPkg.Path() returned the overlay path
'github.com/goplus/llgo/runtime/internal/lib/internal/reflectlite'
instead of the canonical 'internal/reflectlite', causing runtime to
only fill public methods and leave private method pointers NULL.

Changed to use abi.PathOf() which returns the correct canonical package
path for matching, ensuring all interface methods (both public and
private) are properly filled in the interface table.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-27 11:32:38 +00:00
xgopilot
18de107520 Revert "fix(ssa): extract PkgPath from any method, not just private methods"
This reverts commit dee7b873f56a6dd86a9b74cdf8f3ebe49c5ccb98.

The fix didn't resolve the readdir segfault. Need to investigate
more thoroughly by examining LLVM IR output.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-27 09:27:43 +00:00
xgopilot
dee7b873a6 fix(ssa): extract PkgPath from any method, not just private methods
The previous fix only extracted package path from private methods,
causing segfaults for interfaces with only exported methods (like fs.DirEntry).

Root cause:
- For interfaces with only exported methods, the loop never entered
  the !token.IsExported(mName) block
- pkgPath remained empty and fell back to pkg.Path() (compilation package)
- This caused wrong PkgPath for standard library interfaces like fs.DirEntry
- Runtime received wrong package path, leading to segfaults

Fix:
- Extract pkgPath from the FIRST method (any method), not just private ones
- All methods have correct package information via m.Pkg()
- Only fall back to pkg.Path() if the interface has no methods or m.Pkg() is nil

This fixes the readdir demo segfault while maintaining the fix for issue #1370.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-27 09:07:35 +00:00
xgopilot
dba9bcc4e4 fix(ssa): use correct package path for interface metadata in abiInterfaceOf
When converting concrete type pointers to interfaces with private methods
across packages, the interface metadata's PkgPath was incorrectly set 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), which led to segmentation faults when
calling these private methods.

The fix extracts the package path from the interface's private methods
(if any) instead of using the current package path. This ensures the
runtime receives the correct package path for the visibility check.

Fixes #1370

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-23 10:30:00 +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