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

[Bug] - Error on latest release #235

Closed
sujit-baniya opened this issue Jun 2, 2021 · 6 comments · Fixed by #236
Closed

[Bug] - Error on latest release #235

sujit-baniya opened this issue Jun 2, 2021 · 6 comments · Fixed by #236

Comments

@sujit-baniya
Copy link

I'm getting errors when trying to upgrade to latest version.

unexpected fault address 0x0
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0xcc587d]

goroutine 222 [running]:
runtime.throw(0x15833ab, 0x5)
        /usr/local/go/src/runtime/panic.go:1117 +0x72 fp=0xc0020577f0 sp=0xc0020577c0 pc=0x440052
runtime.sigpanic()
        /usr/local/go/src/runtime/signal_unix.go:741 +0x268 fp=0xc002057828 sp=0xc0020577f0 pc=0x457768
github.com/goccy/go-json/internal/encoder.AppendString(0xc0003680c0, 0xc000f29400, 0x177, 0x400, 0x663a2264696c6156, 0x74222c7d65736c61, 0xc0003fbde8, 0x0, 0xc000f29400)
        /home/sujit/go/pkg/mod/github.com/goccy/go-json@v0.6.0/internal/encoder/string.go:422 +0xfd fp=0xc002057900 sp=0xc002057828 pc=0xcc587d
github.com/goccy/go-json/internal/encoder/vm.Run(0xc0003680c0, 0xc000f29400, 0x177, 0x400, 0xc000e92e80, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/sujit/go/pkg/mod/github.com/goccy/go-json@v0.6.0/internal/encoder/vm/vm.go:114 +0x20ea fp=0xc0020589c0 sp=0xc002057900 pc=0xcfe8ea
github.com/goccy/go-json.encodeRunCode(0xc0003680c0, 0xc000f29400, 0x0, 0x400, 0xc000e92e80, 0x10, 0x10, 0xc00204caa0, 0x490eb4, 0x21e5540)
        /home/sujit/go/pkg/mod/github.com/goccy/go-json@v0.6.0/encode.go:266 +0x1f8 fp=0xc002058a20 sp=0xc0020589c0 pc=0xd58a18
github.com/goccy/go-json.encode(0xc0003680c0, 0x1364860, 0xc000f3a200, 0xc0009d59e0, 0x10, 0x41667b, 0xc00160f6d0, 0x10)
        /home/sujit/go/pkg/mod/github.com/goccy/go-json@v0.6.0/encode.go:191 +0x215 fp=0xc002058ab0 sp=0xc002058a20 pc=0xd58635
github.com/goccy/go-json.marshal(0x1364860, 0xc000f3a200, 0x0, 0x0, 0x0, 0x203000, 0x0, 0x14e3560, 0x10, 0xc00160f6d0)
        /home/sujit/go/pkg/mod/github.com/goccy/go-json@v0.6.0/encode.go:106 +0xd3 fp=0xc002058b38 sp=0xc002058ab0 pc=0xd58293
github.com/goccy/go-json.MarshalWithOption(...)
        /home/sujit/go/pkg/mod/github.com/goccy/go-json@v0.6.0/json.go:168
github.com/goccy/go-json.Marshal(0x1364860, 0xc000f3a200, 0x80, 0x78, 0x15054e0, 0x10, 0x10)
        /home/sujit/go/pkg/mod/github.com/goccy/go-json@v0.6.0/json.go:158 +0x46 fp=0xc002058b98 sp=0xc002058b38 pc=0xd58ac6
github.com/sujit-baniya/verify-rest/pkg/asynq/lib/base.EncodeMessage(...)
        /home/sujit/Sites/projects/sms/verify-rest/pkg/asynq/lib/base/base.go:189
github.com/sujit-baniya/verify-rest/pkg/asynq/lib/rdb.(*RDB).Enqueue(0xc000162cd0, 0xc000f3a200, 0x60b739da, 0xbc47632d30fc8ad2)
        /home/sujit/Sites/projects/sms/verify-rest/pkg/asynq/lib/rdb/rdb.go:55 +0x3e fp=0xc002058c20 sp=0xc002058b98 pc=0x108bc9e
github.com/sujit-baniya/verify-rest/pkg/asynq.(*Client).enqueue(0xc000e8a5d0, 0xc000f3a200, 0x0, 0xc025ec56b0fc8ad2, 0x185bec6cc4)
        /home/sujit/Sites/projects/sms/verify-rest/pkg/asynq/client.go:369 +0x86 fp=0xc002058c58 sp=0xc002058c20 pc=0x109ff26
github.com/sujit-baniya/verify-rest/pkg/asynq.(*Client).Enqueue(0xc000e8a5d0, 0xc00204cef0, 0xc00204cf08, 0x2, 0x2, 0xc001936000, 0xc00204cf10, 0x501925)
        /home/sujit/Sites/projects/sms/verify-rest/pkg/asynq/client.go:344 +0x5b0 fp=0xc002058ea8 sp=0xc002058c58 pc=0x109f7d0
github.com/sujit-baniya/verify-rest/internal/services.SendSms(0x0, 0xc025ec56b0f998ad, 0x185be97aa3, 0x23a1f40, 0xc0015c4348, 0x14, 0xc000648a08, 0x14, 0xc0015c42e8, 0x14, ...)
        /home/sujit/Sites/projects/sms/verify-rest/internal/services/sms_service.go:128 +0x18b fp=0xc002059150 sp=0xc002058ea8 pc=0x11d170b
github.com/sujit-baniya/verify-rest/internal/services.SendCampaignPost(0xc00041c780, 0x1, 0xa, 0xc00012b228, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /home/sujit/Sites/projects/sms/verify-rest/internal/services/sms_service.go:214 +0xb14 fp=0xc002059e90 sp=0xc002059150 pc=0x11d2914
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1371 +0x1 fp=0xc002059e98 sp=0xc002059e90 pc=0x477c41
created by github.com/sujit-baniya/verify-rest/rest/controllers.SendCampaignPost
        /home/sujit/Sites/projects/sms/verify-rest/rest/controllers/sms_controller.go:150 +0x250

goroutine 1 [chan receive, 1 minutes]:
github.com/sujit-baniya/verify-rest/config.(*ServerConfig).ServeWithGraceFullShutdown(0xc0000aa990, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/sujit/Sites/projects/sms/verify-rest/config/server.go:109 +0x208
github.com/sujit-baniya/verify-rest/cmd.Execute()
        /home/sujit/Sites/projects/sms/verify-rest/cmd/root.go:47 +0x465
main.main()
        /home/sujit/Sites/projects/sms/verify-rest/main.go:6 +0x25

goroutine 6 [select]:
github.com/gofiber/storage/memory.(*Storage).gc(0xc000224960)
        /home/sujit/go/pkg/mod/github.com/gofiber/storage/memory@v0.0.0-20210531075317-fe9649ddfb4e/memory.go:104 +0x18d
created by github.com/gofiber/storage/memory.New
        /home/sujit/go/pkg/mod/github.com/gofiber/storage/memory@v0.0.0-20210531075317-fe9649ddfb4e/memory.go:34 +0xd9

goroutine 7 [select]:
github.com/gofiber/storage/memory.(*Storage).gc(0xc0003f49c0)
        /home/sujit/go/pkg/mod/github.com/gofiber/storage/memory@v0.0.0-20210531075317-fe9649ddfb4e/memory.go:104 +0x18d
created by github.com/gofiber/storage/memory.New
        /home/sujit/go/pkg/mod/github.com/gofiber/storage/memory@v0.0.0-20210531075317-fe9649ddfb4e/memory.go:34 +0xd9

goroutine 18 [select]:
github.com/gofiber/storage/memory.(*Storage).gc(0xc00068e030)
        /home/sujit/go/pkg/mod/github.com/gofiber/storage/memory@v0.0.0-20210531075317-fe9649ddfb4e/memory.go:104 +0x18d
created by github.com/gofiber/storage/memory.New
        /home/sujit/go/pkg/mod/github.com/gofiber/storage/memory@v0.0.0-20210531075317-fe9649ddfb4e/memory.go:34 +0xd9

goroutine 19 [select, 1 minutes]:
github.com/go-redis/redis/v8/internal/pool.(*ConnPool).reaper(0xc0006a4000, 0xdf8475800)
        /home/sujit/go/pkg/mod/github.com/go-redis/redis/v8@v8.9.0/internal/pool/pool.go:455 +0xd7
created by github.com/go-redis/redis/v8/internal/pool.NewConnPool
        /home/sujit/go/pkg/mod/github.com/go-redis/redis/v8@v8.9.0/internal/pool/pool.go:110 +0x1fc

goroutine 204 [chan receive, 1 minutes]:
github.com/valyala/fasthttp/stackless.funcWorker(0xc00007e300, 0x177cf28)
        /home/sujit/go/pkg/mod/github.com/valyala/fasthttp@v1.26.0/stackless/func.go:53 +0x8d
created by github.com/valyala/fasthttp/stackless.NewFunc.func1
        /home/sujit/go/pkg/mod/github.com/valyala/fasthttp@v1.26.0/stackless/func.go:30 +0x85

goroutine 203 [chan receive, 1 minutes]:
github.com/valyala/fasthttp/stackless.funcWorker(0xc00007e300, 0x177cf28)
        /home/sujit/go/pkg/mod/github.com/valyala/fasthttp@v1.26.0/stackless/func.go:53 +0x8d
created by github.com/valyala/fasthttp/stackless.NewFunc.func1
        /home/sujit/go/pkg/mod/github.com/valyala/fasthttp@v1.26.0/stackless/func.go:30 +0x85

goroutine 202 [chan receive, 1 minutes]:
github.com/valyala/fasthttp/stackless.funcWorker(0xc00007e300, 0x177cf28)
        /home/sujit/go/pkg/mod/github.com/valyala/fasthttp@v1.26.0/stackless/func.go:53 +0x8d
created by github.com/valyala/fasthttp/stackless.NewFunc.func1
        /home/sujit/go/pkg/mod/github.com/valyala/fasthttp@v1.26.0/stackless/func.go:30 +0x85

goroutine 201 [chan receive, 1 minutes]:
github.com/valyala/fasthttp/stackless.funcWorker(0xc00007e300, 0x177cf28)
        /home/sujit/go/pkg/mod/github.com/valyala/fasthttp@v1.26.0/stackless/func.go:53 +0x8d
created by github.com/valyala/fasthttp/stackless.NewFunc.func1
        /home/sujit/go/pkg/mod/github.com/valyala/fasthttp@v1.26.0/stackless/func.go:30 +0x85

goroutine 200 [chan receive, 1 minutes]:
github.com/valyala/fasthttp/stackless.funcWorker(0xc00007e300, 0x177cf28)
        /home/sujit/go/pkg/mod/github.com/valyala/fasthttp@v1.26.0/stackless/func.go:53 +0x8d
created by github.com/valyala/fasthttp/stackless.NewFunc.func1... (3 KB left)
@goccy
Copy link
Owner

goccy commented Jun 2, 2021

@sujit-baniya
I can't debug with this information only, so could you use json.Debug() option to output the debug information ?

@sujit-baniya
Copy link
Author

sujit-baniya commented Jun 2, 2021

@goccy Where should I put json.Debug()

@goccy Issue is replicated using this code:

type TaskMessage struct {
	Type string
	Payload map[string]interface{}
	UniqueKey string
}
func main() {
	msg := TaskMessage{
		Payload: map[string]interface{}{
			"sent_at": map[string]interface{}{
				"Time": "0001-01-01T00:00:00Z",
				"Valid": false,
			},
		},
	}
	b, err := json.Marshal(msg)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(b))
}

It seems the order in the struct matters. If UniqueKey is above Payload, it works

@goccy
Copy link
Owner

goccy commented Jun 2, 2021

@sujit-baniya
Please use json.MarshalWithOption instead of json.Marshal and add it to the argument.
If you are using Encoder ( streaming ) , please use EncodeWithOption as well .

@sujit-baniya
Copy link
Author

sujit-baniya commented Jun 2, 2021

@goccy I've added code to replicate the issue

type TaskMessage struct {
	Type string
	Payload map[string]interface{}
	UniqueKey string
}
func main() {
	msg := TaskMessage{
		Payload: map[string]interface{}{
			"sent_at": map[string]interface{}{
				"Time": "0001-01-01T00:00:00Z",
				"Valid": false,
			},
		},
	}
	b, err := json.Marshal(msg)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(b))
}

@goccy
Copy link
Owner

goccy commented Jun 2, 2021

Thank you for the more detail information. I will fix this issue with #236

@goccy goccy closed this as completed in #236 Jun 2, 2021
@goccy
Copy link
Owner

goccy commented Jun 2, 2021

@sujit-baniya I released v0.6.1 for fixing this issue . Please try it 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants