-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'SagerNet:dev' into dev
- Loading branch information
Showing
3 changed files
with
43 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//go:build !disable_unsafe && !go1.21 | ||
|
||
package buf | ||
|
||
import ( | ||
"unsafe" | ||
|
||
"github.com/sagernet/sing/common" | ||
) | ||
|
||
type dbgVar struct { | ||
name string | ||
value *int32 | ||
} | ||
|
||
//go:linkname dbgvars runtime.dbgvars | ||
var dbgvars any | ||
|
||
// go.info.runtime.dbgvars: relocation target go.info.[]github.com/sagernet/sing/common/buf.dbgVar not defined | ||
// var dbgvars []dbgVar | ||
|
||
func init() { | ||
if !common.UnsafeBuffer { | ||
return | ||
} | ||
debugVars := *(*[]dbgVar)(unsafe.Pointer(&dbgvars)) | ||
for _, v := range debugVars { | ||
if v.name == "invalidptr" { | ||
*v.value = 0 | ||
return | ||
} | ||
} | ||
panic("can't disable invalidptr") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters