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

BenchmarkParseNumber in scanner_test.go #8

Open
ivanburak opened this issue Jan 5, 2021 · 1 comment · May be fixed by #9
Open

BenchmarkParseNumber in scanner_test.go #8

ivanburak opened this issue Jan 5, 2021 · 1 comment · May be fixed by #9

Comments

@ivanburak
Copy link

ivanburak commented Jan 5, 2021

func BenchmarkParseNumber(b *testing.B) {

Hi Dave
I think a small change should be done for this func()
To see an issue quickly just run this line

go test -bench=.Parse.

`

panic: runtime error: index out of range [0] with length 0

goroutine 290 [running]:
github.com/pkg/json.BenchmarkParseNumber.func1(0xc000194240)
C:/Users/VE/go/dev/src/davecheney/pkg/json-master/scanner_test.go:157 +0x51
testing.(*B).runN(0xc000194240, 0x1)
C:/Go/src/testing/benchmark.go:191 +0xf2
testing.(*B).run1.func1(0xc000194240)
C:/Go/src/testing/benchmark.go:231 +0x5e
created by testing.(*B).run1
C:/Go/src/testing/benchmark.go:224 +0x85
exit status 2
`

// --------------------------------------------------------------------------------------------------------------

`

		for i := 0; i < b.N; i++ {
			r.Seek(0, 0)
			scanner := &Scanner{
				br: byteReader{
					data: buf[:0],
					r:    r,
				},
			}
			scanner.Next()                                       // add scanner.Next() here to escape panic
			n := scanner.parseNumber(scanner.br.window(0)[0])    // panic was here

`

tech10 added a commit to tech10/json that referenced this issue Apr 29, 2021
@tech10 tech10 linked a pull request Apr 29, 2021 that will close this issue
@AlexanderYastrebov
Copy link

Looks like it was fixed by 00534bc

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