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/go: trace http viewer: "http: multiple response.WriteHeader calls" #11508

Closed
josharian opened this issue Jul 2, 2015 · 5 comments
Closed
Milestone

Comments

@josharian
Copy link
Contributor

To reproduce:

  • Generate a trace
  • go tool trace foo.test trace.out
  • In the browser, click on "Goroutine analysis" and then click on any given goroutine.

Result:

The server logs: "2015/07/01 18:04:01 http: multiple response.WriteHeader calls"

@josharian josharian added this to the Go1.5 milestone Jul 2, 2015
@dvyukov
Copy link
Member

dvyukov commented Jul 2, 2015

I cannot reproduce it.
Please add traceback (using runtime.Stack) to WriteHeader and check who is calling it the second time.

@josharian
Copy link
Contributor Author

write header for 0xc8200b0370
/Users/jbleechersnyder/src/go/src/net/http/server.go:683 (0xba9ef)
    (*response).WriteHeader: debug.PrintStack()
/Users/jbleechersnyder/src/go/src/net/http/server.go:1067 (0xbd1f8)
    (*response).write: w.WriteHeader(StatusOK)
/Users/jbleechersnyder/src/go/src/net/http/server.go:1053 (0xbd064)
    (*response).Write: return w.write(len(data), data, "")
/Users/jbleechersnyder/src/go/src/encoding/json/stream.go:173 (0x15bd5b)
    (*Encoder).Encode: if _, err = enc.w.Write(e.Bytes()); err != nil {
/Users/jbleechersnyder/src/go/src/cmd/trace/trace.go:96 (0x6b55)
    httpJsonTrace: err = json.NewEncoder(w).Encode(generateTrace(params))
/Users/jbleechersnyder/src/go/src/net/http/server.go:1358 (0xbea4a)
    HandlerFunc.ServeHTTP: f(w, r)
/Users/jbleechersnyder/src/go/src/net/http/server.go:1635 (0xc02ad)
    (*ServeMux).ServeHTTP: h.ServeHTTP(w, r)
/Users/jbleechersnyder/src/go/src/net/http/server.go:1798 (0xc0dde)
    serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/Users/jbleechersnyder/src/go/src/net/http/server.go:1297 (0xbe53a)
    (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/Users/jbleechersnyder/src/go/src/runtime/asm_amd64.s:1696 (0x657b1)
    goexit: BYTE    $0x90   // NOP
write header for 0xc8200b0370
/Users/jbleechersnyder/src/go/src/net/http/server.go:683 (0xba9ef)
    (*response).WriteHeader: debug.PrintStack()
/Users/jbleechersnyder/src/go/src/net/http/server.go:1368 (0xbeb4a)
    Error: w.WriteHeader(code)
/Users/jbleechersnyder/src/go/src/cmd/trace/trace.go:98 (0x6c89)
    httpJsonTrace: http.Error(w, fmt.Sprintf("failed to serialize trace: %v", err), http.StatusInternalServerError)
/Users/jbleechersnyder/src/go/src/net/http/server.go:1358 (0xbea4a)
    HandlerFunc.ServeHTTP: f(w, r)
/Users/jbleechersnyder/src/go/src/net/http/server.go:1635 (0xc02ad)
    (*ServeMux).ServeHTTP: h.ServeHTTP(w, r)
/Users/jbleechersnyder/src/go/src/net/http/server.go:1798 (0xc0dde)
    serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/Users/jbleechersnyder/src/go/src/net/http/server.go:1297 (0xbe53a)
    (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/Users/jbleechersnyder/src/go/src/runtime/asm_amd64.s:1696 (0x657b1)
    goexit: BYTE    $0x90   // NOP
2015/07/02 09:58:23 http: multiple response.WriteHeader calls

@dvyukov
Copy link
Member

dvyukov commented Jul 2, 2015

OK, I see.

But what is the error during json serialization:
httpJsonTrace: http.Error(w, fmt.Sprintf("failed to serialize trace: %v", err), http.StatusInternalServerError)
?
What does it output?

That's a more important issue to fix, because it should not fail in the first place.

@gopherbot
Copy link

CL https://golang.org/cl/11864 mentions this issue.

@dvyukov dvyukov closed this as completed in 11f50f4 Jul 2, 2015
@josharian
Copy link
Contributor Author

The json serialization error turns out to just be "write: broken pipe". It's because my traces were too large. So not really a problem, just a bit of needless terminal noise. I don't see a way to inspect the error at runtime to see whether it is a broken pipe, so I guess (at least for now) there's nothing further to do here.

@golang golang locked and limited conversation to collaborators Jul 1, 2016
@rsc rsc unassigned dvyukov Jun 23, 2022
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

3 participants