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>
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>
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>