Skip to content

text/template: Slice bound out of range error in text/template #53218

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

Closed
secsys-go opened this issue Jun 3, 2022 · 3 comments
Closed

text/template: Slice bound out of range error in text/template #53218

secsys-go opened this issue Jun 3, 2022 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@secsys-go
Copy link

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

$ go version
go version go1.17.8 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE="auto"
GOARCH="amd64"
GOBIN="/home/zjx/workspace/gowork/bin"
GOCACHE="/home/zjx/.cache/go-build"
GOENV="/home/zjx/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/zjx/workspace/gowork/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/zjx/workspace/gowork"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/home/zjx/.local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/zjx/.local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.8"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/zjx/workspace/gowork/src/go-fdg-exmaples/std/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1878510231=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I created an illegal text to parse as template.
A link on go.dev is : Poc.go

What did you expect to see?

It parses failed and return (nil, error)

What did you see instead?

It trigger a slice out of range fatal error, like:

panic: runtime error: slice bounds out of range [:12] with length 11

goroutine 6 [running]:
text/template/parse.(*lexer).emit(...)
	/usr/local/go-faketime/src/text/template/parse/lex.go:163
text/template/parse.lexRightDelim(0xc000108000)
	/usr/local/go-faketime/src/text/template/parse/lex.go:354 +0x29a
text/template/parse.(*lexer).run(0xc000108000)
	/usr/local/go-faketime/src/text/template/parse/lex.go:236 +0x2a
created by text/template/parse.lex
	/usr/local/go-faketime/src/text/template/parse/lex.go:229 +0x1ca

Program exited.
@secsys-go secsys-go changed the title affected/package: Slice bound out of range error in text/template text/template: Slice bound out of range error in text/template Jun 3, 2022
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 3, 2022
@seankhliao
Copy link
Member

cc @robpike

@robpike robpike self-assigned this Jun 3, 2022
@seankhliao
Copy link
Member

I think #52527 is similar/dup?

@ianlancetaylor
Copy link
Contributor

Yes, this is a dup. Don't use whitespace in delimiters.

@ianlancetaylor ianlancetaylor closed this as not planned Won't fix, can't repro, duplicate, stale Jun 6, 2022
@rsc rsc unassigned robpike Jun 22, 2022
@golang golang locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants