Closed Whichbfj28 closed 2 years ago
这是百度的结果。。非专业,不知道正确与否。看是否能给你帮助。 使用GO指针的时候,出现 panic: runtime error: invalid memory address or nil pointer dereference,这其实是典型的Go 指针声明后没有对指针先初始化而直接赋值导致的错误 new初始化值的内存地址,预先分配一个内存地址到指针。
package main
func main() { var i int i = new(int) i=1 }
错误代码:
run 1 panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x493279]
goroutine 1 [running]: os.(Process).signal(0x7b5100?, {0x8c4770?, 0xaaadf8?}) D:/compiler/go/src/os/exec_unix.go:63 +0x39 os.(Process).Signal(...) D:/compiler/go/src/os/exec.go:138 os.(Process).kill(...) D:/compiler/go/src/os/exec_posix.go:67 os.(Process).Kill(...) D:/compiler/go/src/os/exec.go:123 Txray/xray.Stop() E:/code/go/Txray/xray/service.go:120 +0x45 Txray/xray.run({0x8c54c8, 0xc0002008f0}) E:/code/go/Txray/xray/service.go:87 +0x3e Txray/xray.Start({0xc0002420ec, 0x1}) E:/code/go/Txray/xray/service.go:32 +0x139 Txray/cmd.InitServiceShell.func1(0xc0001b6000?) E:/code/go/Txray/cmd/xray.go:17 +0x2b github.com/abiosoft/ishell.(Shell).handleCommand(0xc0001b6000, {0xc000028a00, 0x2, 0x2}) E:/gopath/pkg/mod/github.com/abiosoft/ishell@v2.0.0+incompatible/ishell.go:250 +0xec github.com/abiosoft/ishell.handleInput(0xc0001b6000, {0xc000028a00, 0x2, 0x2}) E:/gopath/pkg/mod/github.com/abiosoft/ishell@v2.0.0+incompatible/ishell.go:204 +0x31 github.com/abiosoft/ishell.(Shell).run(0xc0001b6000) E:/gopath/pkg/mod/github.com/abiosoft/ishell@v2.0.0+incompatible/ishell.go:183 +0x2ef github.com/abiosoft/ishell.(*Shell).Run(0xc0001ba000?) E:/gopath/pkg/mod/github.com/abiosoft/ishell@v2.0.0+incompatible/ishell.go:99 +0x28 main.main()
报错好像和 #13 一样,估计xray没有执行权限
确实是权限问题 chmod -R 0777 程序目录 搞定
系统:alpine 3 版本:Txray - Xray Shell Client - v3.0.6
这是百度的结果。。非专业,不知道正确与否。看是否能给你帮助。 使用GO指针的时候,出现 panic: runtime error: invalid memory address or nil pointer dereference,这其实是典型的Go 指针声明后没有对指针先初始化而直接赋值导致的错误 new初始化值的内存地址,预先分配一个内存地址到指针。
package main
func main() { var i int i = new(int) i=1 }
错误代码:
goroutine 1 [running]: os.(Process).signal(0x7b5100?, {0x8c4770?, 0xaaadf8?}) D:/compiler/go/src/os/exec_unix.go:63 +0x39 os.(Process).Signal(...) D:/compiler/go/src/os/exec.go:138 os.(Process).kill(...) D:/compiler/go/src/os/exec_posix.go:67 os.(Process).Kill(...) D:/compiler/go/src/os/exec.go:123 Txray/xray.Stop() E:/code/go/Txray/xray/service.go:120 +0x45 Txray/xray.run({0x8c54c8, 0xc0002008f0}) E:/code/go/Txray/xray/service.go:87 +0x3e Txray/xray.Start({0xc0002420ec, 0x1}) E:/code/go/Txray/xray/service.go:32 +0x139 Txray/cmd.InitServiceShell.func1(0xc0001b6000?) E:/code/go/Txray/cmd/xray.go:17 +0x2b github.com/abiosoft/ishell.(Shell).handleCommand(0xc0001b6000, {0xc000028a00, 0x2, 0x2}) E:/gopath/pkg/mod/github.com/abiosoft/ishell@v2.0.0+incompatible/ishell.go:250 +0xec github.com/abiosoft/ishell.handleInput(0xc0001b6000, {0xc000028a00, 0x2, 0x2}) E:/gopath/pkg/mod/github.com/abiosoft/ishell@v2.0.0+incompatible/ishell.go:204 +0x31 github.com/abiosoft/ishell.(Shell).run(0xc0001b6000) E:/gopath/pkg/mod/github.com/abiosoft/ishell@v2.0.0+incompatible/ishell.go:183 +0x2ef github.com/abiosoft/ishell.(*Shell).Run(0xc0001ba000?) E:/gopath/pkg/mod/github.com/abiosoft/ishell@v2.0.0+incompatible/ishell.go:99 +0x28 main.main()