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

time: Parse panic: runtime error: index out of range #21113

Closed
Metalnem opened this Issue Jul 21, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@Metalnem

Metalnem commented Jul 21, 2017

What version of Go are you using (go version)?

go version go1.9beta2 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/Metalnem/Go"
GORACE=""
GOROOT="/Users/Metalnem/sdk/go1.9beta2"
GOTOOLDIR="/Users/Metalnem/sdk/go1.9beta2/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/3z/yh79t82n1fj5s0lxsjk9559m0000gn/T/go-build999022073=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

Run following program:

package main

import (
	"time"
)

func main() {
	time.Parse("_2 Jan 06 15:04 MST", "4 --- 00 00:00 GMT")
}

Also available here.

What did you expect to see?

The program should end silently.

What did you see instead?

The program panics:

panic: runtime error: index out of range

goroutine 1 [running]:
time.daysIn(...)
	/Users/Metalnem/sdk/go1.9beta2/src/time/time.go:1036
time.parse(0x108003a, 0x13, 0x107fe4d, 0x12, 0x10c1ec0, 0x10c3300, 0x2, 0x2, 0xc420018100, 0x34, ...)
	/Users/Metalnem/sdk/go1.9beta2/src/time/format.go:1039 +0x3616
time.Parse(0x108003a, 0x13, 0x107fe4d, 0x12, 0xc420018100, 0x0, 0x0, 0xc42003df70, 0x105f6d4)
	/Users/Metalnem/sdk/go1.9beta2/src/time/format.go:767 +0x68
main.main()
	/Users/Metalnem/Temp/main.go:8 +0x4b
exit status 2

@ianlancetaylor ianlancetaylor changed the title from time.Parse panic: runtime error: index out of range to time: Parse panic: runtime error: index out of range Jul 21, 2017

@ianlancetaylor

This comment has been minimized.

Show comment
Hide comment
@ianlancetaylor

ianlancetaylor Jul 21, 2017

Contributor

Fails in 1.6, 1.7, 1.8, so not a new regression.

Contributor

ianlancetaylor commented Jul 21, 2017

Fails in 1.6, 1.7, 1.8, so not a new regression.

@ianlancetaylor ianlancetaylor added this to the Go1.10 milestone Jul 21, 2017

@choleraehyq

This comment has been minimized.

Show comment
Hide comment
@choleraehyq

choleraehyq Jul 25, 2017

Contributor

Hello, I want to make a contribution on this issue, but what the correct behaviour when month is ---?

Contributor

choleraehyq commented Jul 25, 2017

Hello, I want to make a contribution on this issue, but what the correct behaviour when month is ---?

@gopherbot

This comment has been minimized.

Show comment
Hide comment
@gopherbot

gopherbot commented Jul 25, 2017

CL https://golang.org/cl/51010 mentions this issue.

@gopherbot gopherbot closed this in 32e117d Sep 8, 2017

@golang golang locked and limited conversation to collaborators Sep 8, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.