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

"checkptr: pointer arithmetic result points to invalid allocation" caused by #81 #84

Closed
aaron42net opened this issue Mar 27, 2021 · 2 comments · Fixed by #85
Closed
Assignees
Labels
bug Something isn't working

Comments

@aaron42net
Copy link

Using segmentio/encoding v0.2.16 on both MacOS and Linux with Go 1.16.2, I get fatal error: checkptr: pointer arithmetic result points to invalid allocation from Go's race detector pointing a finger at ascii/valid_print.go:31 with certain input to json.Marshal(), suggesting it is related to #81.

Here's simplified test code to trigger it:

package main

import (
	"testing"

	"github.com/segmentio/encoding/json"
)

type Foo struct {
	Source struct {
		Table string
	}
}

func TestUnmarshal(t *testing.T) {
	input := []byte(`{"source": {"table": "1234567"}}`)
	r := &Foo{}
	json.Unmarshal(input, r)
}

Run:

go mod init segtest
go mod tidy
go test -v -race -trimpath ./...

And you should see:

fatal error: checkptr: pointer arithmetic result points to invalid allocation

goroutine 19 [running]:
runtime.throw(0x12669e8, 0x40)
	runtime/panic.go:1117 +0x72 fp=0xc000042b28 sp=0xc000042af8 pc=0x1078352
runtime.checkptrArithmetic(0xc00012a060, 0xc000042bc8, 0x1, 0x1)
	runtime/checkptr.go:43 +0xbe fp=0xc000042b58 sp=0xc000042b28 pc=0x1047b7e
github.com/segmentio/encoding/ascii.ValidPrintString(0xc00012a040, 0x20, 0x1)
	github.com/segmentio/encoding@v0.2.16/ascii/valid_print.go:31 +0x4e5 fp=0xc000042be0 sp=0xc000042b58 pc=0x11d2725
github.com/segmentio/encoding/ascii.ValidPrint(...)
	github.com/segmentio/encoding@v0.2.16/ascii/valid_print.go:8
github.com/segmentio/encoding/json.internalParseFlags(0xc00012a040, 0x20, 0x20, 0xc000121380)
	github.com/segmentio/encoding@v0.2.16/json/parse.go:33 +0xcb fp=0xc000042c68 sp=0xc000042be0 pc=0x120420b
github.com/segmentio/encoding/json.Parse(0xc00012a040, 0x20, 0x20, 0x1223620, 0xc00011a520, 0x0, 0x10, 0xc000030640, 0xc00011a520, 0x138f720, ...)
	github.com/segmentio/encoding@v0.2.16/json/json.go:303 +0x114 fp=0xc000042dd0 sp=0xc000042c68 pc=0x1203a94
github.com/segmentio/encoding/json.Unmarshal(0xc00012a040, 0x20, 0x20, 0x1223620, 0xc00011a520, 0x0, 0x0)
	github.com/segmentio/encoding@v0.2.16/json/json.go:285 +0x93 fp=0xc000042e78 sp=0xc000042dd0 pc=0x1203833
segtest.TestUnmarshal(0xc000102900)
	segtest/main_test.go:18 +0x108 fp=0xc000042ed0 sp=0xc000042e78 pc=0x1213b68

If you can't reproduce, I'd be happy to provide more detail.

@achille-roussel achille-roussel self-assigned this Mar 27, 2021
@achille-roussel achille-roussel added the bug Something isn't working label Mar 27, 2021
@achille-roussel
Copy link
Contributor

Thanks for reporting @aaron42net, I'm looking into this.

@achille-roussel
Copy link
Contributor

The fix was released in v0.2.17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants