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

text/template: calling .Parse on an uninitialized template panics #11226

Closed
mwhudson opened this issue Jun 15, 2015 · 2 comments
Closed

text/template: calling .Parse on an uninitialized template panics #11226

mwhudson opened this issue Jun 15, 2015 · 2 comments
Milestone

Comments

@mwhudson
Copy link
Contributor

I found this in the tests of an old version of go.crypto:

mwhudson@glamdring:~$ cat repro.go
package main

import "text/template"

var tmpl template.Template

func main() {
    tmpl.Parse("")
}
mwhudson@glamdring:~$ go version
go version devel +348f191 Tue Jun 16 10:43:54 2015 +1200 linux/amd64
mwhudson@glamdring:~$ go run repro.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x468f41]

goroutine 1 [running]:
text/template.(*Template).Parse(0x642a60, 0x0, 0x0, 0x7f8a9d0d00a8, 0x0, 0x0)
    /opt/opensource/go/src/text/template/template.go:180 +0x361
main.main()
    /home/mwhudson/repro.go:8 +0x2f
exit status 2
mwhudson@glamdring:~$ ~/go1.4/bin/go run repro.go
@dspezia
Copy link
Contributor

dspezia commented Jun 18, 2015

It fails trying to lock the mutex added by https://go-review.googlesource.com/10101, but this is actually a consequence of https://go-review.googlesource.com/10240 ...
The behavior has clearly changed, but is calling Parse on a uninitialized Template legit?

@mwhudson
Copy link
Contributor Author

See #11379

@mikioh mikioh added this to the Go1.5 milestone Jun 24, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
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