[go] internal/profile: return error from gzip.Writer.Close in Profile.Write

0 views
Skip to first unread message

David Chase (Gerrit)

unread,
1:10 PM (5 hours ago) 1:10 PM
to Gerrit Bot, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Michael Pratt, golang...@luci-project-accounts.iam.gserviceaccount.com, Ian Lance Taylor, Cherry Mui, Gopher Robot, golang-co...@googlegroups.com

David Chase submitted the change

Change information

Commit message:
internal/profile: return error from gzip.Writer.Close in Profile.Write

Profile.Write defers gzip.Writer.Close without checking its return
value. Close flushes buffered data and writes the gzip footer (CRC32
checksum and size). If the flush or footer write fails, the caller
receives a nil error despite the output being truncated or corrupt.

This is called by runtime/pprof and net/http/pprof to serialize
profiles. A write error during gzip finalization (e.g., broken pipe,
full disk) produces corrupt output reported as success.

Remove the defer and call Close explicitly after Write, returning
its error. On Write failure, Close is still called to release
resources, but the Write error is returned.

Fixes #79423
Change-Id: I1d93c20158010f45c72d57caf5d5b25b72ca7511
GitHub-Last-Rev: cd79f2a4cf61f6e175207706f040f21c2c037180
GitHub-Pull-Request: golang/go#79424
Reviewed-by: Michael Pratt <mpr...@google.com>
Reviewed-by: David Chase <drc...@google.com>
Files:
  • M src/internal/profile/profile.go
Change size: XS
Delta: 1 file changed, 5 insertions(+), 3 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I1d93c20158010f45c72d57caf5d5b25b72ca7511
Gerrit-Change-Number: 778280
Gerrit-PatchSet: 2
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages