From 43fef1dae66e581309d62bb4421df4d07683a49c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 5 Aug 2025 23:20:42 +0800 Subject: [PATCH] android: Add workaround for tailscale pidfd crash --- cmd/internal/build_libbox/main.go | 2 ++ experimental/libbox/pidfd_android.go | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 experimental/libbox/pidfd_android.go diff --git a/cmd/internal/build_libbox/main.go b/cmd/internal/build_libbox/main.go index 2b81ff36..de470eb3 100644 --- a/cmd/internal/build_libbox/main.go +++ b/cmd/internal/build_libbox/main.go @@ -112,6 +112,8 @@ func buildAndroid() { args = append(args, debugFlags...) } + args = append(args, "-ldflags", "-checklinkname=0") + tags := append(sharedTags, memcTags...) if debugEnabled { tags = append(tags, debugTags...) diff --git a/experimental/libbox/pidfd_android.go b/experimental/libbox/pidfd_android.go new file mode 100644 index 00000000..cc7cdd7a --- /dev/null +++ b/experimental/libbox/pidfd_android.go @@ -0,0 +1,19 @@ +package libbox + +import ( + "os" + _ "unsafe" +) + +// https://github.com/SagerNet/sing-box/issues/3233 +// https://github.com/golang/go/issues/70508 +// https://github.com/tailscale/tailscale/issues/13452 + +//go:linkname checkPidfdOnce os.checkPidfdOnce +var checkPidfdOnce func() error + +func init() { + checkPidfdOnce = func() error { + return os.ErrInvalid + } +}