From 27dcea35068c25feb565e9b46f863dd1153337f6 Mon Sep 17 00:00:00 2001 From: Chao Wang Date: Wed, 2 Sep 2026 12:19:49 -0700 Subject: [PATCH] Fix empty inode paths caused by stack movement The inode path request stored the result buffer address as an integer, which could become stale if the Go stack moved before the syscall. Pin the buffer while the ioctl runs so ScoutFS writes to the address that Go later reads. --- go.mod | 2 +- scoutfs.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index ff1e768..008d840 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/versity/scoutfs-go -go 1.16 +go 1.26 diff --git a/scoutfs.go b/scoutfs.go index 74ba189..71fe189 100644 --- a/scoutfs.go +++ b/scoutfs.go @@ -16,6 +16,7 @@ import ( "math" "os" "path/filepath" + "runtime" "strconv" "strings" "syscall" @@ -230,6 +231,10 @@ type inoPathResult struct { // (usually just the base mount point directory) func InoToPath(dirfd *os.File, ino uint64) (string, error) { var res inoPathResult + // Result_ptr is an integer, so keep its target at a stable address. + var pin runtime.Pinner + pin.Pin(&res) + defer pin.Unpin() ip := inoPath{ Ino: ino, Result_ptr: uint64(uintptr(unsafe.Pointer(&res))), @@ -251,6 +256,10 @@ func InoToPath(dirfd *os.File, ino uint64) (string, error) { // (usually just the base mount point directory) func InoToPaths(dirfd *os.File, ino uint64) ([]string, error) { var res inoPathResult + // Result_ptr is an integer, so keep its target at a stable address. + var pin runtime.Pinner + pin.Pin(&res) + defer pin.Unpin() ip := inoPath{ Ino: ino, Result_ptr: uint64(uintptr(unsafe.Pointer(&res))),