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 ...@@ -11,7 +11,6 @@ package http
import ( import (
"bufio" "bufio"
"bytes"
"crypto/tls" "crypto/tls"
"errors" "errors"
"fmt" "fmt"
...@@ -21,7 +20,7 @@ import ( ...@@ -21,7 +20,7 @@ import (
"net" "net"
"net/url" "net/url"
"path" "path"
"runtime/debug" "runtime"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
...@@ -610,10 +609,10 @@ func (c *conn) serve() { ...@@ -610,10 +609,10 @@ func (c *conn) serve() {
return return
} }
var buf bytes.Buffer const size = 4096
fmt.Fprintf(&buf, "http: panic serving %v: %v\n", c.remoteAddr, err) buf := make([]byte, size)
buf.Write(debug.Stack()) buf = buf[:runtime.Stack(buf, false)]
log.Print(buf.String()) log.Printf("http: panic serving %v: %v\n%s", c.remoteAddr, err, buf)
if c.rwc != nil { // may be nil if connection hijacked if c.rwc != nil { // may be nil if connection hijacked
c.rwc.Close() 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