Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(124)

Issue 5563045: code review 5563045: bytes.Buffer: restore panic on out-of-memory (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 11 months ago by r
Modified:
13 years, 11 months ago
Reviewers:
rsc, fw, gri, r2
CC:
golang-dev, minux1, bradfitz
Visibility:
Public.

Description

bytes.Buffer: restore panic on out-of-memory Make the panic detectable, and use that in ioutil.ReadFile to give an error if the file is too big.

Patch Set 1 #

Patch Set 2 : diff -r d5b106da84c9 https://code.google.com/p/go/ #

Total comments: 3

Patch Set 3 : diff -r f8a0481e130a https://code.google.com/p/go/ #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+35 lines, -22 lines) Patch
M src/pkg/bytes/buffer.go View 6 chunks +10 lines, -15 lines 3 comments Download
M src/pkg/bytes/buffer_test.go View 1 2 1 chunk +10 lines, -5 lines 0 comments Download
M src/pkg/io/ioutil/ioutil.go View 1 1 chunk +15 lines, -2 lines 0 comments Download

Messages

Total messages: 10
r
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go/
13 years, 11 months ago (2012-01-21 17:38:35 UTC) #1
minux1
http://codereview.appspot.com/5563045/diff/5/src/pkg/bytes/buffer_test.go File src/pkg/bytes/buffer_test.go (right): http://codereview.appspot.com/5563045/diff/5/src/pkg/bytes/buffer_test.go#newcode408 src/pkg/bytes/buffer_test.go:408: t.Error("error expected") s/error/panic/ ?
13 years, 11 months ago (2012-01-21 17:43:28 UTC) #2
bradfitz
LGTM On Jan 21, 2012 11:38 AM, <r@golang.org> wrote: > Reviewers: golang-dev_googlegroups.com, > > Message: ...
13 years, 11 months ago (2012-01-21 17:45:29 UTC) #3
r
*** Submitted as b372a927701e *** bytes.Buffer: restore panic on out-of-memory Make the panic detectable, and ...
13 years, 11 months ago (2012-01-21 17:47:03 UTC) #4
gri
I am not convinced by this CL. It seems to me that Write was the ...
13 years, 11 months ago (2012-01-21 17:50:49 UTC) #5
rsc
b.ReadFrom(r) is essentially defined as a shortcut for r.Read(tmp)+b.Write(tmp). It should behave the same as ...
13 years, 11 months ago (2012-01-21 17:59:26 UTC) #6
fw
http://codereview.appspot.com/5563045/diff/7/src/pkg/bytes/buffer.go File src/pkg/bytes/buffer.go (right): http://codereview.appspot.com/5563045/diff/7/src/pkg/bytes/buffer.go#newcode171 src/pkg/bytes/buffer.go:171: panic(ErrTooLarge) I don't think this is thread-safe. (The old ...
13 years, 11 months ago (2012-01-22 21:48:58 UTC) #7
r
http://codereview.appspot.com/5563045/diff/7/src/pkg/bytes/buffer.go File src/pkg/bytes/buffer.go (right): http://codereview.appspot.com/5563045/diff/7/src/pkg/bytes/buffer.go#newcode171 src/pkg/bytes/buffer.go:171: panic(ErrTooLarge) In what sense is it not thread safe? ...
13 years, 11 months ago (2012-01-22 21:59:02 UTC) #8
fw
http://codereview.appspot.com/5563045/diff/7/src/pkg/bytes/buffer.go File src/pkg/bytes/buffer.go (right): http://codereview.appspot.com/5563045/diff/7/src/pkg/bytes/buffer.go#newcode171 src/pkg/bytes/buffer.go:171: panic(ErrTooLarge) On 2012/01/22 21:59:02, r wrote: > In what ...
13 years, 11 months ago (2012-01-23 07:17:28 UTC) #9
r2
13 years, 11 months ago (2012-01-23 07:32:07 UTC) #10
On Jan 22, 2012, at 11:17 PM, fw@deneb.enyo.de wrote:

> 
> http://codereview.appspot.com/5563045/diff/7/src/pkg/bytes/buffer.go
> File src/pkg/bytes/buffer.go (right):
> 
>
http://codereview.appspot.com/5563045/diff/7/src/pkg/bytes/buffer.go#newcode171
> src/pkg/bytes/buffer.go:171: panic(ErrTooLarge)
> On 2012/01/22 21:59:02, r wrote:
>> In what sense is it not thread safe? The allocation failed, so this
> thread is
>> unhappy anyway.
> 
> Returning the error attributes the cause to the buffer operation.  But
> that's not necessarily the case if another thread uses up the heap in
> parallel.  True, the allocation has failed, but does this really convey
> any information to the caller in such a case?

Errors aren't about cause, they're about facts. The fact is the allocation
failed. There's little else to do in any case.

-rob


Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b