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

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

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

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

Metalnem opened this issue Jul 21, 2017 · 3 comments

Comments

@Metalnem
Copy link

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 time.Parse panic: runtime error: index out of range time: Parse panic: runtime error: index out of range Jul 21, 2017
@ianlancetaylor
Copy link
Contributor

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

@choleraehyq
Copy link
Contributor

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

@gopherbot
Copy link
Contributor

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

@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.
Projects
None yet
Development

No branches or pull requests

4 participants