Commit dd43bf80 authored by Dave Cheney's avatar Dave Cheney

net/http: use runtime.Stack instead of runtime/debug.Stack

Fixes #4060.

2012/11/21 19:51:34 http: panic serving 127.0.0.1:47139: Kaaarn!
goroutine 7 [running]:
net/http.func·004(0x7f330807ffb0, 0x7f330807f100)
	/home/dfc/go/src/pkg/net/http/server.go:615 +0xa7
----- stack segment boundary -----
main.(*httpHandler).ServeHTTP()
	/home/dfc/src/httppanic.go:16 +0x53
net/http.(*conn).serve(0xc200090240, 0x0)
	/home/dfc/go/src/pkg/net/http/server.go:695 +0x55d
created by net/http.(*Server).Serve
	/home/dfc/go/src/pkg/net/http/server.go:1119 +0x36d

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6846085
parent dd01e928
......@@ -11,7 +11,6 @@ package http
import (
"bufio"
"bytes"
"crypto/tls"
"errors"
"fmt"
......@@ -21,7 +20,7 @@ import (
"net"
"net/url"
"path"
"runtime/debug"
"runtime"
"strconv"
"strings"
"sync"
......@@ -610,10 +609,10 @@ func (c *conn) serve() {
return
}
var buf bytes.Buffer
fmt.Fprintf(&buf, "http: panic serving %v: %v\n", c.remoteAddr, err)
buf.Write(debug.Stack())
log.Print(buf.String())
const size = 4096
buf := make([]byte, size)
buf = buf[:runtime.Stack(buf, false)]
log.Printf("http: panic serving %v: %v\n%s", c.remoteAddr, err, buf)
if c.rwc != nil { // may be nil if connection hijacked
c.rwc.Close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment