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.

Golang cgocall(asmstdcallAddr, unsafe.Pointer(c))  Segmentation fault

What did you expect to see?

normal running not Segmentation fault

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

Comment From: cherrymui

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

Thanks.

Comment From: gopherbot

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)