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

cmd/godoc: panics when attempting to serve a pkg doc page with empty ExampleXXX #3092

Closed
kortschak opened this issue Feb 21, 2012 · 4 comments
Milestone

Comments

@kortschak
Copy link
Contributor

Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull", "hg update default", rebuild, and
retry
what you did to
reproduce the problem.  Thanks.

Tried building tip (as with previous report) could not build to get commands to test.
Apologies.

What steps will reproduce the problem?
1. Create the package main as with attached files.
2. godoc -http=:6060
3. Point browser to appropriate path of localhost:6060

What is the expected output?
On browser: Boring doc page.
On Terminal: no error.

What do you see instead?
On browser: timeout.
On terminal:
2012/02/21 15:39:19 http: panic serving [::1]:47659: runtime error: slice bounds out of
range
/usr/local/src/go/src/pkg/net/http/server.go:577 (0x471a28)
    _func_002: buf.Write(debug.Stack())
/usr/local/src/go/src/pkg/runtime/proc.c:1389 (0x433c87)
    panic: reflect·call(d->fn, d->args, d->siz);
/usr/local/src/go/src/pkg/text/template/exec.go:84 (0x48f2b9)
    errRecover: panic(e)
/usr/local/src/go/src/pkg/runtime/proc.c:1389 (0x433c87)
    panic: reflect·call(d->fn, d->args, d->siz);
/usr/local/src/go/src/pkg/runtime/runtime.c:128 (0x434814)
    panicstring: runtime·panic(err);
/usr/local/src/go/src/pkg/runtime/runtime.c:91 (0x4346e5)
    panicslice: runtime·panicstring("slice bounds out of range");
/usr/local/src/go/src/pkg/runtime/zstring_amd64.c:253 (0x43a521)
    slicestring: runtime·panicslice();
/usr/local/src/go/src/cmd/godoc/godoc.go:524 (0x4092ac)
    example_htmlFunc: code = code[2 : len(code)-2]
/usr/local/src/go/src/pkg/reflect/value.go:517 (0x531db5)
    Value.call: call(fn, unsafe.Pointer(ptr), uint32(size))
/usr/local/src/go/src/pkg/reflect/value.go:330 (0x5309bb)
    Value.Call: return v.call("Call", in)
/usr/local/src/go/src/pkg/text/template/exec.go:494 (0x493073)
    (*state).evalCall: result := fun.Call(argv)
/usr/local/src/go/src/pkg/text/template/exec.go:394 (0x491f00)
    (*state).evalFunction: return s.evalCall(dot, function, name, args, final)
/usr/local/src/go/src/pkg/text/template/exec.go:320 (0x491197)
    (*state).evalCommand: return s.evalFunction(dot, n.Ident, cmd.Args, final)
/usr/local/src/go/src/pkg/text/template/exec.go:295 (0x490c2d)
    (*state).evalPipeline: value = s.evalCommand(dot, cmd, value) // previous value is this one's final arg.
/usr/local/src/go/src/pkg/text/template/exec.go:129 (0x48f83d)
    (*state).walk: val := s.evalPipeline(dot, n.Pipe)
/usr/local/src/go/src/pkg/text/template/exec.go:138 (0x48fd58)
    (*state).walk: s.walk(dot, node)
/usr/local/src/go/src/pkg/text/template/exec.go:222 (0x499ed9)
    _func_001: s.walk(elem, r.List)
/usr/local/src/go/src/pkg/text/template/exec.go:231 (0x4905e0)
    (*state).walkRange: oneIteration(reflect.ValueOf(i), val.Index(i))
/usr/local/src/go/src/pkg/text/template/exec.go:142 (0x48f92b)
    (*state).walk: s.walkRange(dot, n)
/usr/local/src/go/src/pkg/text/template/exec.go:138 (0x48fd58)
    (*state).walk: s.walk(dot, node)
/usr/local/src/go/src/pkg/text/template/exec.go:171 (0x48ffc4)
    (*state).walkIfOrWith: s.walk(dot, list)
/usr/local/src/go/src/pkg/text/template/exec.go:135 (0x48fb6a)
    (*state).walk: s.walkIfOrWith(parse.NodeIf, dot, n.Pipe, n.List, n.ElseList)
/usr/local/src/go/src/pkg/text/template/exec.go:138 (0x48fd58)
    (*state).walk: s.walk(dot, node)
/usr/local/src/go/src/pkg/text/template/exec.go:169 (0x48ff52)
    (*state).walkIfOrWith: s.walk(val, list)
/usr/local/src/go/src/pkg/text/template/exec.go:152 (0x48fc02)
    (*state).walk: s.walkIfOrWith(parse.NodeWith, dot, n.Pipe, n.List, n.ElseList)
/usr/local/src/go/src/pkg/text/template/exec.go:138 (0x48fd58)
    (*state).walk: s.walk(dot, node)
/usr/local/src/go/src/pkg/text/template/exec.go:117 (0x48f6b5)
    (*Template).Execute: state.walk(value, t.Root)
/usr/local/src/go/src/cmd/godoc/godoc.go:747 (0x40ad1d)
    applyTemplate: if err := t.Execute(&buf, data); err != nil {
/usr/local/src/go/src/cmd/godoc/godoc.go:1224 (0x40dc00)
    (*httpHandler).ServeHTTP: contents := applyTemplate(packageHTML, "packageHTML", info)
/usr/local/src/go/src/pkg/net/http/server.go:925 (0x466951)
    (*ServeMux).ServeHTTP: mux.handler(r).ServeHTTP(w, r)
/usr/local/src/go/src/pkg/net/http/server.go:657 (0x4658e2)
    (*conn).serve: handler.ServeHTTP(w, w.req)
/usr/local/src/go/src/pkg/runtime/proc.c:258 (0x431e81)
    goexit: runtime·goexit(void)


Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
Linux Ubuntu Lucid

Which revision are you using?  (hg identify)
weekly.2012-02-1

Please provide any additional information below.

Attachments:

  1. main.go (45 bytes)
  2. example_test.go (36 bytes)
@kortschak
Copy link
Contributor Author

Comment 1:

Lost digit: weekly.2012-02-14

@dsymonds
Copy link
Contributor

Comment 2:

Labels changed: added priority-go1, go1-must, toolbug, removed priority-triage.

Owner changed to @adg.

@griesemer
Copy link
Contributor

Comment 4:

Status changed to Started.

@griesemer
Copy link
Contributor

Comment 5:

This issue was closed by revision 775f005.

Status changed to Fixed.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc unassigned adg Jun 22, 2022
This issue was closed.
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

6 participants