compress/flate: fix overflow on 2GB input. Reset hashOffset every 16 MB.
This bug has been introduced in the following revision:
changeset: 11404:26dceba5c610
user: Ivan Krasin <krasin@golang.org>
date: Mon Jan 23 09:19:39 2012 -0500
summary: compress/flate: reduce memory pressure at cost of additional arithmetic operation.
This is the review page for that CL: http://codereview.appspot.com/5555070/
Looks good. Now that you understand the bug, is it possible to write a simple ...
11 years, 11 months ago
(2012-05-30 03:19:10 UTC)
#2
Looks good. Now that you understand the bug, is it possible to write a
simple test that will trigger it (one that doesn't require a 2GB input
file)? It would be good to have such a test that was disabled for
testing.Short() but run during long tests.
Thanks.
Russ
Hi Russ, I have added the test (a very long, sparse input). Also, I don't ...
11 years, 11 months ago
(2012-05-30 17:11:21 UTC)
#3
Hi Russ,
I have added the test (a very long, sparse input). Also, I don't run
DeflateInflateTest on the inputs larger than a threshold.
Short tests for compress/flate run 0.8 sec on my machine and large tests run 16
sec. This might be a problem on ARM.
I patched this in, reverted deflate.go, and changed 2*maxHashOffset to 1<<25 in the test, and ...
11 years, 11 months ago
(2012-05-30 17:23:01 UTC)
#4
I patched this in, reverted deflate.go, and changed 2*maxHashOffset to
1<<25 in the test, and the test passes. I was hoping for a test that
fails without this CL. Is that possible?
Thanks.
Russ
On 2012/05/30 17:25:21, imkrasin wrote: > Just a sec. My estimation was about 3600x more ...
11 years, 11 months ago
(2012-05-30 18:26:12 UTC)
#6
On 2012/05/30 17:25:21, imkrasin wrote:
> Just a sec.
My estimation was about 3600x more optimistic than the reality, but the test is
ready. Please, take a look. It works ~ 15 sec on my machine.
The idea of the test: the bug is reproduced when hashHead contains a very (> ...
11 years, 11 months ago
(2012-05-30 18:31:13 UTC)
#7
The idea of the test: the bug is reproduced when hashHead contains a very (> 2GB
ago) stale reference that is being requested. So, the test satisfies:
111111111 <many zeros> 111111111
because most of the time we update the same hash.
Thanks for working out a test. http://codereview.appspot.com/6249067/diff/6004/src/pkg/compress/flate/deflate_test.go File src/pkg/compress/flate/deflate_test.go (right): http://codereview.appspot.com/6249067/diff/6004/src/pkg/compress/flate/deflate_test.go#newcode103 src/pkg/compress/flate/deflate_test.go:103: type sparseReader struct ...
11 years, 11 months ago
(2012-05-30 18:39:18 UTC)
#8
On 2012/05/30 20:08:52, rsc wrote: > LGTM > > Thanks for all the revisions. I ...
11 years, 11 months ago
(2012-05-30 20:21:55 UTC)
#12
On 2012/05/30 20:08:52, rsc wrote:
> LGTM
>
> Thanks for all the revisions. I feel good about this fix now.
Thank for showing me ioutil.Discard (I tend to look at types and methods in the
docs, and frequently ignore vars).
Sorry for yet another bug in my code.
Issue 6249067: compress/flate: fix overflow on 2GB input. Reset hashOf...
Created 11 years, 11 months ago by Ivan Krasin
Modified 10 years, 9 months ago
Reviewers: imkrasin
Base URL:
Comments: 10