Open zhuzaiye opened 1 year ago
build command: go build -v -tags=jsoniter -o elst-primary-api2 main.go will cause this error but: go build -v -o elst-primary-api2 withoud -tags=jsoniter will not cause this error
env:
- go 1.18
- gin 1.7.4
reason is "reflect2 package relies on unsafe and unsupported techniques, and must exactly match the version of Go that you are using" ???
unexpected fault address 0x0 fatal error: fault [signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x460e3f] goroutine 13 [running]: runtime.throw({0x107fd39?, 0x413b85?}) C:/Golang/go1.18/src/runtime/panic.go:992 +0x71 fp=0xc000092ec0 sp=0xc000092e90 pc=0x434111 runtime.sigpanic() C:/Golang/go1.18/src/runtime/signal_unix.go:825 +0x2ec fp=0xc000092f10 sp=0xc000092ec0 pc=0x44954c aeshashbody() C:/Golang/go1.18/src/runtime/asm_amd64.s:1343 +0x39f fp=0xc000092f18 sp=0xc000092f10 pc=0x460e3f runtime.mapiternext(0xc00010d100) C:/Golang/go1.18/src/runtime/map.go:934 +0x2cb fp=0xc000092f88 sp=0xc000092f18 pc=0x40faab runtime.mapiterinit(0x40d2c5?, 0xc000037088?, 0xc0000bb330?) C:/Golang/go1.18/src/runtime/map.go:861 +0x228 fp=0xc000092fa8 sp=0xc000092f88 pc=0x40f788 reflect.mapiterinit(0xf392e0?, 0xc000676908?, 0xc0000930b8?) C:/Golang/go1.18/src/runtime/map.go:1373 +0x19 fp=0xc000092fd0 sp=0xc000092fa8 pc=0x45d999 github.com/modern-go/reflect2.(*UnsafeMapType).UnsafeIterate(...) C:/Golang/goproject/pkg/mod/github.com/modern-go/reflect2@v0.0.0-20180701023420-4b7aa43c6742/unsafe_map.go:112 github.com/json-iterator/go.(*sortKeysMapEncoder).Encode(0xc0001773b0, 0xc0000bb360, 0xc000102180) C:/Golang/goproject/pkg/mod/github.com/json-iterator/go@v1.1.9/reflect_map.go:291 +0x225 fp=0xc000093138 sp=0xc000092fd0 pc=0x78f6a5 github.com/json-iterator/go.(*onePtrEncoder).Encode(0xc000109740, 0xc000176bd0, 0xc00010d100?) C:/Golang/goproject/pkg/mod/github.com/json-iterator/go@v1.1.9/reflect.go:219 +0x82 fp=0xc000093170 sp=0xc000093138 pc=0x787e22 github.com/json-iterator/go.(*Stream).WriteVal(0xc000102180, {0xf52740, 0xc000176bd0}) C:/Golang/goproject/pkg/mod/github.com/json-iterator/go@v1.1.9/reflect.go:98 +0x158 fp=0xc0000931e0 sp=0xc000093170 pc=0x787138 github.com/json-iterator/go.(*dynamicEncoder).Encode(0xc000093278?, 0x79e707?, 0xc000102198?) C:/Golang/goproject/pkg/mod/github.com/json-iterator/go@v1.1.9/reflect_dynamic.go:15 +0x39 fp=0xc000093210 sp=0xc0000931e0 pc=0x789679 github.com/json-iterator/go.(*structFieldEncoder).Encode(0xc0001771a0, 0xea87c1?, 0xc000102180) C:/Golang/goproject/pkg/mod/github.com/json-iterator/go@v1.1.9/reflect_struct_encoder.go:110 +0x56 fp=0xc000093288 sp=0xc000093210 pc=0x79c8b6 github.com/json-iterator/go.(*structEncoder).Encode(0xc000177230, 0x1400f88?, 0xc000102180) C:/Golang/goproject/pkg/mod/github.com/json-iterator/go@v1.1.9/reflect_struct_encoder.go:158 +0x652 fp=0xc000093360 sp=0xc000093288 pc=0x79d1b2 github.com/json-iterator/go.(*Stream).WriteVal(0xc000102180, {0xfd9520, 0xc00010d000}) C:/Golang/goproject/pkg/mod/github.com/json-iterator/go@v1.1.9/reflect.go:98 +0x158 fp=0xc0000933d0 sp=0xc000093360 pc=0x787138 github.com/json-iterator/go.(*frozenConfig).Marshal(0xc000314500, {0xfd9520, 0xc00010d000}) C:/Golang/goproject/pkg/mod/github.com/json-iterator/go@v1.1.9/config.go:299 +0xc9 fp=0xc000093468 sp=0xc0000933d0 pc=0x77e3e9 github.com/json-iterator/go.API.Marshal-fm({0xfd9520?, 0xc00010d000?}) <autogenerated>:1 +0x3e fp=0xc000093490 sp=0xc000093468 pc=0x7a833e github.com/gin-gonic/gin/render.WriteJSON({0x7fd83fd95840, 0xc000402300}, {0xfd9520, 0xc00010d000}) C:/Golang/goproject/pkg/mod/github.com/gin-gonic/gin@v1.7.4/render/json.go:69 +0x63 fp=0xc0000934c8 sp=0xc000093490 pc=0x950bc3 github.com/gin-gonic/gin/render.JSON.Render(...) C:/Golang/goproject/pkg/mod/github.com/gin-gonic/gin@v1.7.4/render/json.go:55 github.com/gin-gonic/gin/render.(*JSON).Render(0xc000109410?, {0x7fd83fd95840?, 0xc000402300?}) <autogenerated>:1 +0x45 fp=0xc0000934f8 sp=0xc0000934c8 pc=0x9534e5 github.com/gin-gonic/gin.(*Context).Render(0xc000402300, 0xc8, {0x13f8c50, 0xc000109410}) C:/Golang/goproject/pkg/mod/github.com/gin-gonic/gin@v1.7.4/context.go:913 +0xf8 fp=0xc000093528 sp=0xc0000934f8 pc=0x95b038 github.com/gin-gonic/gin.(*Context).JSON(...) C:/Golang/goproject/pkg/mod/github.com/gin-gonic/gin@v1.7.4/context.go:956 elst-primary-api/pkg/app.(*Gin).Success(0xf52740?, {0xf52740?, 0xc000176bd0?}) C:/awsomeworks/awsomework_golang/sinewave_go/elst-primary-api/pkg/app/response.go:30 +0xfe fp=0xc0000935e0 sp=0xc000093528 pc=0xc6cefe elst-primary-api/controllers/api/v1.GetAppProtocols(0xc000402300?) C:/awsomeworks/awsomework_golang/sinewave_go/elst-primary-api/controllers/api/v1/opinion_feedback.go:118 +0x3fb fp=0xc000093688 sp=0xc0000935e0 pc=0xe3f9fb github.com/gin-gonic/gin.(*Context).Next(...) C:/Golang/goproject/pkg/mod/github.com/gin-gonic/gin@v1.7.4/context.go:165 elst-primary-api/routers.CorsDomain.func1(0xc000402300) C:/awsomeworks/awsomework_golang/sinewave_go/elst-primary-api/routers/cors_domain.go:19 +0x138 fp=0xc0000936d0 sp=0xc000093688 pc=0xe6aef8 github.com/gin-gonic/gin.(*Context).Next(...) C:/Golang/goproject/pkg/mod/github.com/gin-gonic/gin@v1.7.4/context.go:165 github.com/gin-gonic/gin.CustomRecoveryWithWriter.func1(0xc000402300) C:/Golang/goproject/pkg/mod/github.com/gin-gonic/gin@v1.7.4/recovery.go:99 +0x82 fp=0xc000093720 sp=0xc0000936d0 pc=0x963742 github.com/gin-gonic/gin.(*Context).Next(...) C:/Golang/goproject/pkg/mod/github.com/gin-gonic/gin@v1.7.4/context.go:165 github.com/gin-gonic/gin.LoggerWithConfig.func1(0xc000402300) C:/Golang/goproject/pkg/mod/github.com/gin-gonic/gin@v1.7.4/logger.go:241 +0xe7 fp=0xc0000938d8 sp=0xc000093720 pc=0x962867 github.com/gin-gonic/gin.(*Context).Next(...) C:/Golang/goproject/pkg/mod/github.com/gin-gonic/gin@v1.7.4/context.go:165 github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0xc000003ba0, 0xc000402300) C:/Golang/goproject/pkg/mod/github.com/gin-gonic/gin@v1.7.4/gin.go:489 +0x63e fp=0xc000093a58 sp=0xc0000938d8 pc=0x96191e github.com/gin-gonic/gin.(*Engine).ServeHTTP(0xc000003ba0, {0x13f9ed0?, 0xc000826460}, 0xc000402200) C:/Golang/goproject/pkg/mod/github.com/gin-gonic/gin@v1.7.4/gin.go:445 +0x1c5 fp=0xc000093a98 sp=0xc000093a58 pc=0x961105 net/http.serverHandler.ServeHTTP({0xc000176ab0?}, {0x13f9ed0, 0xc000826460}, 0xc000402200) C:/Golang/go1.18/src/net/http/server.go:2916 +0x43b fp=0xc000093b58 sp=0xc000093a98 pc=0x6ca97b net/http.(*conn).serve(0xc0005750e0, {0x13fab48, 0xc0001769c0}) C:/Golang/go1.18/src/net/http/server.go:1966 +0x5d7 fp=0xc000093fb8 sp=0xc000093b58 pc=0x6c5977 net/http.(*Server).Serve.func3() C:/Golang/go1.18/src/net/http/server.go:3071 +0x2e fp=0xc000093fe0 sp=0xc000093fb8 pc=0x6cb2ce runtime.goexit() C:/Golang/go1.18/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc000093fe8 sp=0xc000093fe0 pc=0x463901 created by net/http.(*Server).Serve C:/Golang/go1.18/src/net/http/server.go:3071 +0x4db
when update gin version to 1.9.1, this bug will not occur.
build command: go build -v -tags=jsoniter -o elst-primary-api2 main.go will cause this error but: go build -v -o elst-primary-api2 withoud -tags=jsoniter will not cause this error
env:
reason is "reflect2 package relies on unsafe and unsupported techniques, and must exactly match the version of Go that you are using" ???