diff --git a/common/buf/ptr.go b/common/buf/ptr.go index 1c26a93..901c9e3 100644 --- a/common/buf/ptr.go +++ b/common/buf/ptr.go @@ -4,6 +4,8 @@ package buf import ( "unsafe" + + "github.com/sagernet/sing/common" ) type dbgVar struct { @@ -17,8 +19,10 @@ var dbgvars any // go.info.runtime.dbgvars: relocation target go.info.[]github.com/sagernet/sing/common/buf.dbgVar not defined // var dbgvars []dbgVar -//nolint:gochecknoinits func init() { + if !common.UnsafeBuffer { + return + } debugVars := *(*[]dbgVar)(unsafe.Pointer(&dbgvars)) for _, v := range debugVars { if v.name == "invalidptr" { diff --git a/common/exceptions/error.go b/common/exceptions/error.go index f43c7e1..64b6468 100644 --- a/common/exceptions/error.go +++ b/common/exceptions/error.go @@ -32,11 +32,8 @@ func Extend(cause error, message ...any) error { return &extendedError{F.ToString(message...), cause} } -//go:linkname errCanceled net.errCanceled -var errCanceled error - func IsClosedOrCanceled(err error) bool { - return IsMulti(err, io.EOF, net.ErrClosed, io.ErrClosedPipe, os.ErrClosed, syscall.EPIPE, syscall.ECONNRESET, context.Canceled, context.DeadlineExceeded, errCanceled) + return IsMulti(err, io.EOF, net.ErrClosed, io.ErrClosedPipe, os.ErrClosed, syscall.EPIPE, syscall.ECONNRESET, context.Canceled, context.DeadlineExceeded) } func IsClosed(err error) bool { @@ -44,5 +41,5 @@ func IsClosed(err error) bool { } func IsCanceled(err error) bool { - return IsMulti(err, context.Canceled, context.DeadlineExceeded, errCanceled) + return IsMulti(err, context.Canceled, context.DeadlineExceeded) }