Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgocall(asmstdcallAddr, unsafe.Pointer(c)) Segmentation fault #67148

Open
kelleygo opened this issue May 3, 2024 · 1 comment
Open

cgocall(asmstdcallAddr, unsafe.Pointer(c)) Segmentation fault #67148

kelleygo opened this issue May 3, 2024 · 1 comment
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@kelleygo
Copy link

kelleygo commented May 3, 2024

Go version

go version go1.22.2 windows/amd64

Output of go env in your module/workspace:

go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\zz\AppData\Local\go-build
set GOENV=C:\Users\zz\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\go\pkg\mod
set GONOPROXY=www.baibu.com
set GONOSUMDB=xx.xx.com
set GOOS=windows
set GOPATH=D:\go
set GOPRIVATE=xx.xx.com
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:/Sortware/Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Sortware\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.2
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\go\src\letsProxy\py-lib\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\zz\AppData\Local\Temp\go-build2221472203=/tmp/go-build -gno-record-gcc-switches

What did you do?

//#include <stdio.h>
import "C"
import (
	"context"
	"github.com/kelleygo/py-lib/service"
	"github.com/kelleygo/sing-box/log"
	"github.com/kelleygo/sing-box/pkg"
	"github.com/kelleygo/sing-box/pkg/vmess"
	"os"
	"os/signal"
	"syscall"
)

var (
	serviceAddr        = "1.2.3.4"
	servicePort uint64 = 443
	uuid               = "x-7cfc-x-x-x"
	logPath            = ".temp.log"
)


func main() {
	var runMode int = 0
	closeCtx, closed := context.WithCancel(context.Background())
	defer closed()
	var service pkg.Tun2VmessService
	service = vmess.NewVmessService(runMode, serviceAddr, servicePort, uuid)
	err := service.Start(closeCtx)
	if err != nil {
		closed()
		return
	}
	for {
		select {
		case <-closeCtx.Done():
			return
		}
	}
}

What did you see happen?

INFO[0000] router: updated default interface eth2, index 19
DEBUG[0000] router: updating rule-set geoip-cn from URL: https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs
DEBUG[0000] router: updating rule-set geosite-cn from URL: https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-cn.srs
DEBUG[0000] router: updating rule-set geosite-geolocation-!cn from URL: https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs
INFO[0000] outbound/vmess[proxy]: outbound connection to raw.githubusercontent.com:443
INFO[0000] outbound/vmess[proxy]: outbound connection to raw.githubusercontent.com:443
INFO[0000] outbound/vmess[proxy]: outbound connection to raw.githubusercontent.com:443
INFO[0001] router: updated rule-set geoip-cn
INFO[0001] router: updated rule-set geosite-cn
INFO[0001] router: updated rule-set geosite-geolocation-!cn
INFO[0001] dns/transport[dns_local]: dhcp: query DNS servers on eth2
INFO[0001] dns/transport[dns_local]: dhcp: updated DNS servers from eth2: [192.168.7.1]

Segmentation fault

Process finished with the exit code -1073741819 (0xC0000005)

When I debug using GDB, an exception occurs during the invocation of cgocall(asmstdcallAddr, unsafe.Pointer(c)) : Segmentation fault; Line number: runtime/syscall_windows.go 544.

image

What did you expect to see?

normal running not Segmentation fault

Process finished with the exit code -1073741819 (0xC0000005)

@cherrymui
Copy link
Member

This could mean that a seg fault occurs in the C code. Could you double check your C code?

Thanks.

@cherrymui cherrymui added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

2 participants