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

compress/gzip: Write over reports bytes written if underlying Writer errors within 10 bytes #24625

Closed
twmb opened this issue Apr 1, 2018 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@twmb
Copy link
Contributor

twmb commented Apr 1, 2018

What version of Go are you using (go version)?

go version go1.10 linux/amd64; exists since 2010

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/twmb/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/twmb/go"
GORACE=""
GOROOT="/home/twmb/go/go"
GOTMPDIR=""
GOTOOLDIR="/home/twmb/go/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build085502795=/tmp/go-build -gno-record-gcc-switches"

What did you do?

https://play.golang.org/p/BtWWmSrhxZk

What did you expect to see?

err: lim 1, wrote: 0
err: lim 2, wrote: 0
err: lim 3, wrote: 0
err: lim 4, wrote: 0
err: lim 5, wrote: 0
err: lim 6, wrote: 0
err: lim 7, wrote: 0
err: lim 8, wrote: 0
err: lim 9, wrote: 0
ok: lim 10, wrote: 1

(continuing with one character in header)

err: lim 10, wrote: 0
err: lim 11, wrote: 0
ok: lim 12, wrote: 1

What did you see instead?

err: lim 1, wrote: 1
err: lim 2, wrote: 2
err: lim 3, wrote: 3
err: lim 4, wrote: 4
err: lim 5, wrote: 5
err: lim 6, wrote: 6
err: lim 7, wrote: 7
err: lim 8, wrote: 8
err: lim 9, wrote: 9
ok: lim 10, wrote: 1

(continuing with one character in header)

err: lim 10, wrote: 10
err: lim 11, wrote: 10
ok: lim 12, wrote: 1

This is due to

n, z.err = z.w.Write(z.buf[:10])
; the gzip writer should not report bytes written that are unrelated to the input slice.

@twmb twmb changed the title compress/gzip: Write overreports bytes written if underlying riter errors within 10 bytes compress/gzip: Write over reports bytes written if underlying Writer errors within 10 bytes Apr 1, 2018
@gopherbot
Copy link

Change https://golang.org/cl/103861 mentions this issue: compress/gzip: do not count header bytes written in Write

@bcmills bcmills added this to the Go1.11 milestone Apr 2, 2018
@bcmills bcmills added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 2, 2018
@golang golang locked and limited conversation to collaborators Apr 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants