Skip to content

Commit

Permalink
Fix disable invalidptr
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Jun 5, 2022
1 parent 066830b commit e0f7225
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions common/buf/ptr.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@
package buf

import (
"os"
"unsafe"
_ "unsafe"
)

//go:linkname parsedebugvars runtime.parsedebugvars
func parsedebugvars()

func init() {
disableInvalidPtrCheck()
type dbgVar struct {
name string
value *int32
}

func disableInvalidPtrCheck() {
debug := os.Getenv("GODEBUG")
if debug == "" {
os.Setenv("GODEBUG", "invalidptr=0")
} else {
os.Setenv("GODEBUG", debug+",invalidptr=0")
//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() {
debugVars := *(*[]dbgVar)(unsafe.Pointer(&dbgvars))
for _, v := range debugVars {
if v.name == "invalidptr" {
*v.value = 0
return
}
}
parsedebugvars()
panic("can't disable invalidptr")
}
Empty file removed common/buf/stub.s
Empty file.

0 comments on commit e0f7225

Please # to comment.